fix(compiler-cli): do not fold errors past calls in the collector (#21708)
Folding errors passed calls prevented the static reflector from begin able to ignore errors in annotations it doesn't know as the call to the unknown annotation was elided from the metadata. Fixes: #21273 PR Close #21708
This commit is contained in:

committed by
Miško Hevery

parent
e82812b9a9
commit
dd8679037e
@ -1054,10 +1054,20 @@ describe('Collector', () => {
|
||||
expect(metadata.metadata.MyComponent).toEqual({
|
||||
__symbolic: 'class',
|
||||
decorators: [{
|
||||
__symbolic: 'error',
|
||||
message: 'Expression form not supported',
|
||||
line: 5,
|
||||
character: 55
|
||||
__symbolic: 'call',
|
||||
expression: {
|
||||
__symbolic: 'reference',
|
||||
module: '@angular/core',
|
||||
name: 'Component',
|
||||
line: 4,
|
||||
character: 9
|
||||
},
|
||||
arguments: [{
|
||||
__symbolic: 'error',
|
||||
message: 'Expression form not supported',
|
||||
line: 5,
|
||||
character: 55
|
||||
}]
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -1698,6 +1698,40 @@ describe('ngc transformer command-line', () => {
|
||||
expect(messages[0]).toContain(`is imported recursively by the module 'MyFaultyImport`);
|
||||
});
|
||||
|
||||
// Regression test for #21273
|
||||
it('should not report errors for unknown property annotations', () => {
|
||||
write('src/tsconfig.json', `{
|
||||
"extends": "../tsconfig-base.json",
|
||||
"files": ["test-module.ts"]
|
||||
}`);
|
||||
|
||||
write('src/test-decorator.ts', `
|
||||
export function Convert(p: any): any {
|
||||
// Make sur this doesn't look like a macro function
|
||||
var r = p;
|
||||
return r;
|
||||
}
|
||||
`);
|
||||
write('src/test-module.ts', `
|
||||
import {Component, Input, NgModule} from '@angular/core';
|
||||
import {Convert} from './test-decorator';
|
||||
|
||||
@Component({template: '{{name}}'})
|
||||
export class TestComponent {
|
||||
@Input() @Convert(convert) name: string;
|
||||
}
|
||||
|
||||
function convert(n: any) { return n; }
|
||||
|
||||
@NgModule({declarations: [TestComponent]})
|
||||
export class TestModule {}
|
||||
`);
|
||||
const messages: string[] = [];
|
||||
expect(
|
||||
main(['-p', path.join(basePath, 'src/tsconfig.json')], message => messages.push(message)))
|
||||
.toBe(0, `Compile failed:\n ${messages.join('\n ')}`);
|
||||
});
|
||||
|
||||
it('should allow using 2 classes with the same name in declarations with noEmitOnError=true',
|
||||
() => {
|
||||
write('src/tsconfig.json', `{
|
||||
|
Reference in New Issue
Block a user