@@ -992,7 +992,9 @@ namespace ts {
992
992
const moduleSymbol = resolveExternalModuleName(node, (<ImportDeclaration>node.parent).moduleSpecifier);
993
993
994
994
if (moduleSymbol) {
995
- const exportDefaultSymbol = moduleSymbol.exports["export="] ?
995
+ const exportDefaultSymbol = isShorthandAmbientModule(moduleSymbol.valueDeclaration) ?
996
+ moduleSymbol :
997
+ moduleSymbol.exports["export="] ?
996
998
getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
997
999
resolveSymbol(moduleSymbol.exports["default"]);
998
1000
@@ -1066,6 +1068,10 @@ namespace ts {
1066
1068
if (targetSymbol) {
1067
1069
const name = specifier.propertyName || specifier.name;
1068
1070
if (name.text) {
1071
+ if (isShorthandAmbientModule(moduleSymbol.valueDeclaration)) {
1072
+ return moduleSymbol;
1073
+ }
1074
+
1069
1075
let symbolFromVariable: Symbol;
1070
1076
// First check if module was specified with "export=". If so, get the member from the resolved type
1071
1077
if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) {
@@ -3234,9 +3240,14 @@ namespace ts {
3234
3240
function getTypeOfFuncClassEnumModule(symbol: Symbol): Type {
3235
3241
const links = getSymbolLinks(symbol);
3236
3242
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
+ }
3240
3251
}
3241
3252
return links.type;
3242
3253
}
@@ -16052,7 +16063,7 @@ namespace ts {
16052
16063
// - augmentation for a global scope is always applied
16053
16064
// - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module).
16054
16065
const checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & SymbolFlags.Merged);
16055
- if (checkBody) {
16066
+ if (checkBody && node.body ) {
16056
16067
// body of ambient external module is always a module block
16057
16068
for (const statement of (<ModuleBlock>node.body).statements) {
16058
16069
checkModuleAugmentationElement(statement, isGlobalAugmentation);
@@ -16079,7 +16090,15 @@ namespace ts {
16079
16090
}
16080
16091
}
16081
16092
}
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
+ }
16083
16102
}
16084
16103
16085
16104
function checkModuleAugmentationElement(node: Node, isGlobalAugmentation: boolean): void {
0 commit comments