@@ -992,7 +992,9 @@ namespace ts {
992992 const moduleSymbol = resolveExternalModuleName(node, (<ImportDeclaration>node.parent).moduleSpecifier);
993993
994994 if (moduleSymbol) {
995- const exportDefaultSymbol = moduleSymbol.exports["export="] ?
995+ const exportDefaultSymbol = isShorthandAmbientModule(moduleSymbol.valueDeclaration) ?
996+ moduleSymbol :
997+ moduleSymbol.exports["export="] ?
996998 getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
997999 resolveSymbol(moduleSymbol.exports["default"]);
9981000
@@ -1066,6 +1068,10 @@ namespace ts {
10661068 if (targetSymbol) {
10671069 const name = specifier.propertyName || specifier.name;
10681070 if (name.text) {
1071+ if (isShorthandAmbientModule(moduleSymbol.valueDeclaration)) {
1072+ return moduleSymbol;
1073+ }
1074+
10691075 let symbolFromVariable: Symbol;
10701076 // First check if module was specified with "export=". If so, get the member from the resolved type
10711077 if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) {
@@ -3234,9 +3240,14 @@ namespace ts {
32343240 function getTypeOfFuncClassEnumModule(symbol: Symbol): Type {
32353241 const links = getSymbolLinks(symbol);
32363242 if (!links.type) {
3237- const type = createObjectType(TypeFlags.Anonymous, symbol);
3238- links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ?
3239- addTypeKind(type, TypeFlags.Undefined) : type;
3243+ if (symbol.valueDeclaration.kind === SyntaxKind.ModuleDeclaration && isShorthandAmbientModule(<ModuleDeclaration>symbol.valueDeclaration)) {
3244+ links.type = anyType;
3245+ }
3246+ else {
3247+ const type = createObjectType(TypeFlags.Anonymous, symbol);
3248+ links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ?
3249+ addTypeKind(type, TypeFlags.Undefined) : type;
3250+ }
32403251 }
32413252 return links.type;
32423253 }
@@ -16052,7 +16063,7 @@ namespace ts {
1605216063 // - augmentation for a global scope is always applied
1605316064 // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module).
1605416065 const checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & SymbolFlags.Merged);
16055- if (checkBody) {
16066+ if (checkBody && node.body ) {
1605616067 // body of ambient external module is always a module block
1605716068 for (const statement of (<ModuleBlock>node.body).statements) {
1605816069 checkModuleAugmentationElement(statement, isGlobalAugmentation);
@@ -16079,7 +16090,15 @@ namespace ts {
1607916090 }
1608016091 }
1608116092 }
16082- checkSourceElement(node.body);
16093+
16094+ if (compilerOptions.noImplicitAny && !node.body) {
16095+ // Ambient shorthand module is an implicit any
16096+ reportImplicitAnyError(node, anyType);
16097+ }
16098+
16099+ if (node.body) {
16100+ checkSourceElement(node.body);
16101+ }
1608316102 }
1608416103
1608516104 function checkModuleAugmentationElement(node: Node, isGlobalAugmentation: boolean): void {
0 commit comments