@@ -2207,7 +2207,7 @@ namespace ts {
2207
2207
}
2208
2208
2209
2209
// May be an untyped module. If so, ignore resolutionDiagnostic.
2210
- if (resolvedModule && !extensionIsTypeScript (resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) {
2210
+ if (resolvedModule && !resolutionExtensionIsTypeScriptOrJson (resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) {
2211
2211
if (isForAugmentation) {
2212
2212
const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
2213
2213
error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
@@ -4718,6 +4718,10 @@ namespace ts {
4718
4718
return links.type = anyType;
4719
4719
}
4720
4720
// Handle export default expressions
4721
+ if (isSourceFile(declaration)) {
4722
+ const jsonSourceFile = cast(declaration, isJsonSourceFile);
4723
+ return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType;
4724
+ }
4721
4725
if (declaration.kind === SyntaxKind.ExportAssignment) {
4722
4726
return links.type = checkExpression((<ExportAssignment>declaration).expression);
4723
4727
}
@@ -15597,7 +15601,7 @@ namespace ts {
15597
15601
const contextualType = getApparentTypeOfContextualType(node);
15598
15602
const contextualTypeHasPattern = contextualType && contextualType.pattern &&
15599
15603
(contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression);
15600
- const isInJSFile = isInJavaScriptFile(node);
15604
+ const isInJSFile = isInJavaScriptFile(node) && !isInJsonFile(node) ;
15601
15605
const isJSObjectLiteral = !contextualType && isInJSFile;
15602
15606
let typeFlags: TypeFlags = 0;
15603
15607
let patternWithComputedProperties = false;
0 commit comments