-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathbaseUrlMigrationExample.js
More file actions
63 lines (53 loc) · 1.69 KB
/
baseUrlMigrationExample.js
File metadata and controls
63 lines (53 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//// [tests/cases/compiler/baseUrlMigrationExample.ts] ////
//// [tsconfig.json]
{
"compilerOptions": {
"paths": {
// Explicit prefix for all path mappings
"@app/*": ["./src/app/*"],
"@lib/*": ["./src/lib/*"],
// Optional: preserve baseUrl behavior with catch-all
"*": ["./src/*"]
}
}
}
//// [module.ts]
export const value = 42;
//// [utils.ts]
export function helper() { return "help"; }
//// [main.ts]
import { value } from "@app/module";
import { helper } from "@lib/utils";
// With explicit catch-all mapping, this still works:
import * as something from "someModule"; // Resolves to ./src/someModule
//// [someModule.ts]
export const data = "from explicit path mapping";
//// [module.ts]
export const value = 42;
//// [utils.ts]
export function helper() { return "help"; }
//// [main.ts]
import { value } from "@app/module";
import { helper } from "@lib/utils";
// This would also resolve due to baseUrl:
import * as something from "someModule"; // Resolves to ./src/someModule
//// [someModule.ts]
export const data = "from baseUrl resolution";
//// [module.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.value = void 0;
exports.value = 42;
//// [utils.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.helper = helper;
function helper() { return "help"; }
//// [someModule.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.data = void 0;
exports.data = "from baseUrl resolution";
//// [main.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });