fix(compiler): Ignore references to declared modules and unneeded types (#9776)

Fixes: #9670
This commit is contained in:
Chuck Jazdzewski
2016-07-11 17:26:35 -07:00
committed by GitHub
parent eb5763c23f
commit 4ef86891a3
7 changed files with 70 additions and 46 deletions

View File

@ -123,7 +123,10 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
const filePath = this.resolve(module, containingFile);
if (!filePath) {
throw new Error(`Could not resolve module ${module} relative to ${containingFile}`);
// If the file cannot be found the module is probably referencing a declared module
// for which there is no disambiguating file and we also don't need to track
// re-exports. Just use the module name.
return this.getStaticSymbol(module, symbolName);
}
const tc = this.program.getTypeChecker();
@ -174,10 +177,12 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
return result;
}
// TODO(alexeagle): take a statictype
getMetadataFor(filePath: string): ModuleMetadata {
if (!this.context.exists(filePath)) {
throw new Error(`No such file '${filePath}'`);
// If the file doesn't exists then we cannot return metadata for the file.
// This will occur if the user refernced a declared module for which no file
// exists for the module (i.e. jQuery or angularjs).
return;
}
if (DTS.test(filePath)) {
const metadataPath = filePath.replace(DTS, '.metadata.json');

View File

@ -474,7 +474,7 @@ export class StaticReflector implements ReflectorReader {
let message = produceErrorMessage(expression);
if (expression['line']) {
message =
`${message} (position ${expression['line']}:${expression['character']} in the original .ts file)`;
`${message} (position ${expression['line']+1}:${expression['character']+1} in the original .ts file)`;
}
throw new Error(message);
}