Merge pull request #26817 from Microsoft/resolvingJsonModuleLikeJsExportsEqual

Use widened type and non fresh type when resolving json module
This commit is contained in:
Sheetal Nandi
2018-09-06 09:49:53 -07:00
committed by GitHub
6 changed files with 191 additions and 7 deletions

View File

@@ -5133,7 +5133,14 @@ namespace ts {
// Handle export default expressions
if (isSourceFile(declaration)) {
const jsonSourceFile = cast(declaration, isJsonSourceFile);
return jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType;
if (!jsonSourceFile.statements.length) {
return emptyObjectType;
}
const type = getWidenedLiteralType(checkExpression(jsonSourceFile.statements[0].expression));
if (type.flags & TypeFlags.Object) {
return getRegularTypeOfObjectLiteral(type);
}
return type;
}
if (declaration.kind === SyntaxKind.ExportAssignment) {
return checkExpression((<ExportAssignment>declaration).expression);