fix(compiler): Missing metadata files should result in undefined (#9704)

RelectorHost threw an exception when metadata was requested for a
.d.ts file that didn't have a .metadata.json file.  Changed it to
return undefined.

Fixes #9678
This commit is contained in:
Chuck Jazdzewski
2016-07-06 14:26:31 -07:00
committed by GitHub
parent 9a04fcd061
commit 30bec78da3
2 changed files with 12 additions and 9 deletions

View File

@ -92,6 +92,10 @@ describe('reflector_host', () => {
() => {
expect(reflectorHost.getMetadataFor('node_modules/@angular/core.d.ts'))
.toEqual({__symbolic: 'module', version: 1, metadata: {foo: {__symbolic: 'class'}}})});
it('should be able to read metadata from an otherwise unused .d.ts file ', () => {
expect(reflectorHost.getMetadataFor('node_modules/@angular/unused.d.ts')).toBeUndefined();
});
});
const dummyModule = 'export let foo: any[];'
@ -115,8 +119,8 @@ const FILES: Entry = {
'core.d.ts': dummyModule,
'core.metadata.json':
`{"__symbolic":"module", "version": 1, "metadata": {"foo": {"__symbolic": "class"}}}`,
'router-deprecated':
{'index.d.ts': dummyModule, 'src': {'providers.d.ts': dummyModule}}
'router-deprecated': {'index.d.ts': dummyModule, 'src': {'providers.d.ts': dummyModule}},
'unused.d.ts': dummyModule
}
}
}