Skip to content

Commit 1418d19

Browse files
alan-agius4thePunderWoman
authored andcommitted
test(compiler): add test case for merging objects in tsconfig (#49125)
This commit adds a test case for validate that we do not deep merge objects like like 'paths' and `extendedDiagnostics`. PR Close #49125
1 parent 1407a9a commit 1418d19

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

packages/compiler-cli/test/perform_compile_spec.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ describe('perform_compile', () => {
195195
}));
196196
});
197197

198-
it('should merge tsconfig "angularCompilerOptions" when extends is an array', () => {
198+
it('should merge tsconfig "angularCompilerOptions" when extends is aarray', () => {
199199
support.writeFiles({
200200
'tsconfig-level-1.json': `{
201201
"extends": [
@@ -242,4 +242,50 @@ describe('perform_compile', () => {
242242
skipMetadataEmit: false,
243243
}));
244244
});
245+
246+
it(`should not deep merge objects. (Ex: 'paths' and 'extendedDiagnostics')`, () => {
247+
support.writeFiles({
248+
'tsconfig-level-1.json': `{
249+
"extends": "./tsconfig-level-2.json",
250+
"compilerOptions": {
251+
"paths": {
252+
"@angular/core": ["/*"]
253+
}
254+
},
255+
"angularCompilerOptions": {
256+
"extendedDiagnostics": {
257+
"checks": {
258+
"textAttributeNotBinding": "suppress"
259+
}
260+
}
261+
}
262+
}
263+
`,
264+
'tsconfig-level-2.json': `{
265+
"compilerOptions": {
266+
"strict": false,
267+
"paths": {
268+
"@angular/common": ["/*"]
269+
}
270+
},
271+
"angularCompilerOptions": {
272+
"skipMetadataEmit": true,
273+
"extendedDiagnostics": {
274+
"checks": {
275+
"nullishCoalescingNotNullable": "suppress"
276+
}
277+
}
278+
}
279+
}
280+
`,
281+
});
282+
283+
const {options} = readConfiguration(path.resolve(basePath, 'tsconfig-level-1.json'));
284+
expect(options).toEqual(jasmine.objectContaining({
285+
strict: false,
286+
skipMetadataEmit: true,
287+
extendedDiagnostics: {checks: {textAttributeNotBinding: 'suppress'}},
288+
paths: {'@angular/core': ['/*']}
289+
}));
290+
});
245291
});

0 commit comments

Comments
 (0)