fix(compiler-cli): do not lower expressions in non-modules (#21649)

Fixes: #21651

PR Close #21649
This commit is contained in:
Chuck Jazdzewski
2018-01-18 14:36:49 -08:00
committed by Miško Hevery
parent 982eb7bba8
commit ba4ea82f68
2 changed files with 14 additions and 3 deletions

View File

@ -325,13 +325,14 @@ export class LowerMetadataCache implements RequestsMap {
};
// Do not validate or lower metadata in a declaration file. Declaration files are requested
// when we need to update the version of the metadata to add informatoin that might be missing
// when we need to update the version of the metadata to add information that might be missing
// in the out-of-date version that can be recovered from the .d.ts file.
const declarationFile = sourceFile.isDeclarationFile;
const moduleFile = ts.isExternalModule(sourceFile);
const metadata = this.collector.getMetadata(
sourceFile, this.strict && !declarationFile,
declarationFile ? undefined : substituteExpression);
moduleFile && !declarationFile ? substituteExpression : undefined);
return {metadata, requests};
}