Skip to content

Commit b578c52

Browse files
committed
refactor: remove deprecated compiler option
Removes usages of the `baseUrl` compiler option which is deprecated and will start throwing an error in TypeScript 6.
1 parent 68bc648 commit b578c52

File tree

14 files changed

+46
-76
lines changed

14 files changed

+46
-76
lines changed

modules/testing/builder/projects/hello-world-app/src/tsconfig.server.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "./tsconfig.app.json",
33
"compilerOptions": {
44
"outDir": "../dist-server",
5-
"baseUrl": "./",
65
"types": ["@angular/localize", "node"]
76
},
87
"files": [

modules/testing/builder/projects/hello-world-app/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"compileOnSave": false,
33
"compilerOptions": {
4-
"baseUrl": "./",
54
"outDir": "./dist/out-tsc",
65
"sourceMap": true,
76
"declaration": false,
@@ -17,7 +16,6 @@
1716
]
1817
},
1918
"angularCompilerOptions": {
20-
"enableIvy": true,
2119
"disableTypeScriptVersionCheck": true,
2220
"strictTemplates": true
2321
}

packages/angular/build/src/builders/application/tests/behavior/typescript-path-mapping_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
8181
await harness.modifyFile('tsconfig.json', (content) => {
8282
const tsconfig = JSON.parse(content);
8383
tsconfig.compilerOptions.paths = {
84-
'app-module': ['a.js'],
84+
'app-module': ['./a.js'],
8585
};
8686

8787
return JSON.stringify(tsconfig);

packages/angular/build/src/builders/application/tests/options/allowed-common-js-dependencies_spec.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,13 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
130130
it('should not show warning in JIT for templateUrl and styleUrl when using paths', async () => {
131131
await harness.modifyFile('tsconfig.json', (content) => {
132132
return content.replace(
133-
/"baseUrl": ".\/",/,
134-
`
135-
"baseUrl": "./",
136-
"paths": {
137-
"@app/*": [
138-
"src/app/*"
139-
]
140-
},
133+
/"compilerOptions": {/,
134+
`"compilerOptions": {
135+
"paths": {
136+
"@app/*": [
137+
"./src/app/*"
138+
]
139+
},
141140
`,
142141
);
143142
});

packages/angular/build/src/builders/karma/tests/options/code-coverage_spec.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
6767

6868
it(`should collect coverage from paths in 'sourceRoot'`, async () => {
6969
await harness.writeFiles({
70-
'./dist/my-lib/index.d.ts': `
70+
'./node_modules/my-lib/index.d.ts': `
7171
export declare const title = 'app';
7272
`,
73-
'./dist/my-lib/index.js': `
73+
'./node_modules/my-lib/index.js': `
7474
export const title = 'app';
7575
`,
7676
'./src/app/app.component.ts': `
@@ -88,20 +88,6 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
8888
}
8989
`,
9090
});
91-
await harness.modifyFile('tsconfig.json', (content) =>
92-
content.replace(
93-
/"baseUrl": ".\/",/,
94-
`
95-
"baseUrl": "./",
96-
"paths": {
97-
"my-lib": [
98-
"./dist/my-lib"
99-
]
100-
},
101-
`,
102-
),
103-
);
104-
10591
harness.useTarget('test', {
10692
...BASE_OPTIONS,
10793
codeCoverage: true,

packages/angular_devkit/build_angular/src/builders/browser/specs/tsconfig-paths_spec.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ describe('Browser Builder tsconfig paths', () => {
2121

2222
it('works', async () => {
2323
host.replaceInFile('src/app/app.module.ts', './app.component', '@root/app/app.component');
24+
25+
// TODO(crisbeto): the `baseUrl` here will trigger a deprecation error in TS6. We may
26+
// have to opt out of it for this test since Webpack seems to depend on the `baseUrl`.
2427
host.replaceInFile(
2528
'tsconfig.json',
26-
/"baseUrl": ".\/",/,
29+
/"compilerOptions": {/,
2730
`
28-
"baseUrl": "./",
29-
"paths": {
30-
"@root/*": [
31-
"./src/*"
32-
]
33-
},
31+
"compilerOptions": {
32+
"baseUrl": "./",
33+
"paths": {
34+
"@root/*": [
35+
"./src/*"
36+
]
37+
},
3438
`,
3539
);
3640

@@ -43,23 +47,27 @@ describe('Browser Builder tsconfig paths', () => {
4347
'src/app/shared/meaning.ts': 'export var meaning = 42;',
4448
'src/app/shared/index.ts': `export * from './meaning'`,
4549
});
50+
51+
// TODO(crisbeto): the `baseUrl` here will trigger a deprecation error in TS6. We may
52+
// have to opt out of it for this test since Webpack seems to depend on the `baseUrl`.
4653
host.replaceInFile(
4754
'tsconfig.json',
48-
/"baseUrl": ".\/",/,
55+
/"compilerOptions": {/,
4956
`
50-
"baseUrl": "./",
51-
"paths": {
52-
"@shared": [
53-
"src/app/shared"
54-
],
55-
"@shared/*": [
56-
"src/app/shared/*"
57-
],
58-
"*": [
59-
"*",
60-
"src/app/shared/*"
61-
]
62-
},
57+
"compilerOptions": {
58+
"baseUrl": "./",
59+
"paths": {
60+
"@shared": [
61+
"./src/app/shared"
62+
],
63+
"@shared/*": [
64+
"./src/app/shared/*"
65+
],
66+
"*": [
67+
"*",
68+
"./src/app/shared/*"
69+
]
70+
},
6371
`,
6472
);
6573
host.appendToFile(

packages/angular_devkit/build_angular/src/builders/browser/tests/options/allowed-common-js-dependencies_spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
120120
it('should not show warning in JIT for templateUrl and styleUrl when using paths', async () => {
121121
await harness.modifyFile('tsconfig.json', (content) => {
122122
return content.replace(
123-
/"baseUrl": ".\/",/,
124-
`
123+
/"compilerOptions": {/,
124+
// TODO(crisbeto): the `baseUrl` here will trigger a deprecation error in TS6. We may
125+
// have to opt out of it for this test since Webpack seems to depend on the `baseUrl`.
126+
`"compilerOptions": {
125127
"baseUrl": "./",
126128
"paths": {
127129
"@app/*": [
128-
"src/app/*"
130+
"./src/app/*"
129131
]
130132
},
131133
`,

packages/angular_devkit/build_angular/src/builders/karma/tests/options/code-coverage_spec.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
6767

6868
it(`should collect coverage from paths in 'sourceRoot'`, async () => {
6969
await harness.writeFiles({
70-
'./dist/my-lib/index.d.ts': `
70+
'./node_modules/my-lib/index.d.ts': `
7171
export declare const title = 'app';
7272
`,
73-
'./dist/my-lib/index.js': `
73+
'./node_modules/my-lib/index.js': `
7474
export const title = 'app';
7575
`,
7676
'./src/app/app.component.ts': `
@@ -88,20 +88,6 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
8888
}
8989
`,
9090
});
91-
await harness.modifyFile('tsconfig.json', (content) =>
92-
content.replace(
93-
/"baseUrl": ".\/",/,
94-
`
95-
"baseUrl": "./",
96-
"paths": {
97-
"my-lib": [
98-
"./dist/my-lib"
99-
]
100-
},
101-
`,
102-
),
103-
);
104-
10591
harness.useTarget('test', {
10692
...BASE_OPTIONS,
10793
codeCoverage: true,

packages/angular_devkit/build_angular/test/hello-world-lib/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"compileOnSave": false,
33
"compilerOptions": {
4-
"baseUrl": "./",
54
"outDir": "./dist/out-tsc",
65
"sourceMap": true,
76
"declaration": false,
@@ -16,7 +15,6 @@
1615
]
1716
},
1817
"angularCompilerOptions": {
19-
"enableIvy": true,
2018
"disableTypeScriptVersionCheck": true
2119
}
2220
}

packages/angular_devkit/build_webpack/test/angular-app/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"compileOnSave": false,
33
"compilerOptions": {
4-
"baseUrl": "./",
54
"outDir": "./dist/out-tsc",
65
"sourceMap": true,
76
"declaration": false,
@@ -12,7 +11,6 @@
1211
"lib": ["es2022", "dom"]
1312
},
1413
"angularCompilerOptions": {
15-
"enableIvy": true,
1614
"disableTypeScriptVersionCheck": true
1715
}
1816
}

0 commit comments

Comments
 (0)