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

@ -184,14 +184,13 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
if (this.context.exists(metadataPath)) {
return this.readMetadata(metadataPath);
}
} else {
const sf = this.program.getSourceFile(filePath);
if (!sf) {
throw new Error(`Source file ${filePath} not present in program.`);
}
return this.metadataCollector.getMetadata(sf);
}
let sf = this.program.getSourceFile(filePath);
if (!sf) {
throw new Error(`Source file ${filePath} not present in program.`);
}
const metadata = this.metadataCollector.getMetadata(sf);
return metadata;
}
readMetadata(filePath: string) {