fix(compiler-cli): do not validate metadata from declaration files (#19324)

Upgrading metadata files causes spurious reports of metadata errors.

Fixes #18867
This commit is contained in:
Chuck Jazdzewski
2017-09-25 12:36:08 -07:00
committed by Victor Berchet
parent 68078fd620
commit 476790290e
2 changed files with 39 additions and 1 deletions

View File

@ -98,6 +98,38 @@ describe('Expression lowering', () => {
expect(collected.requests.has(collected.annotations[0].start))
.toBeTruthy('did not find the data field');
});
it('should throw a validation execption for invalid files', () => {
const cache = new LowerMetadataCache({}, /* strict */ true);
const sourceFile = ts.createSourceFile(
'foo.ts', `
import {Injectable} from '@angular/core';
class SomeLocalClass {}
@Injectable()
export class SomeClass {
constructor(a: SomeLocalClass) {}
}
`,
ts.ScriptTarget.Latest, true);
expect(() => cache.getMetadata(sourceFile)).toThrow();
});
it('should not report validation errors on a .d.ts file', () => {
const cache = new LowerMetadataCache({}, /* strict */ true);
const dtsFile = ts.createSourceFile(
'foo.d.ts', `
import {Injectable} from '@angular/core';
class SomeLocalClass {}
@Injectable()
export class SomeClass {
constructor(a: SomeLocalClass) {}
}
`,
ts.ScriptTarget.Latest, true);
expect(() => cache.getMetadata(dtsFile)).not.toThrow();
});
});
});