fix(ivy): ensure @nocollapse is added to static fields (#28050)
ngtsc has a hack to add @nocollapse jsdoc annotations to generated static fields. This hack is currently broken (likely due to a TypeScript change in the way writeFile() works). This commit fixes the hack and introduces an ngtsc_spec test to ensure it does not regress again. PR Close #28050
This commit is contained in:

committed by
Andrew Kushnir

parent
df292c2ce0
commit
61bc61fc59
@ -109,6 +109,27 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(jsContents).toContain('Hello World');
|
||||
});
|
||||
|
||||
it('should add @nocollapse to static fields when closure annotations are requested', () => {
|
||||
env.tsconfig({
|
||||
'annotateForClosureCompiler': true,
|
||||
});
|
||||
env.write('test.ts', `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'test-cmp',
|
||||
templateUrl: './dir/test.html',
|
||||
})
|
||||
export class TestCmp {}
|
||||
`);
|
||||
env.write('dir/test.html', '<p>Hello World</p>');
|
||||
|
||||
env.driveMain();
|
||||
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('/** @nocollapse */ TestCmp.ngComponentDef');
|
||||
});
|
||||
|
||||
it('should compile Components with a templateUrl in a different rootDir', () => {
|
||||
env.tsconfig({}, ['./extraRootDir']);
|
||||
env.write('extraRootDir/test.html', '<p>Hello World</p>');
|
||||
|
Reference in New Issue
Block a user