Skip to content

Commit

Permalink
Move errorType for import.defer handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jan 17, 2025
1 parent 2a8e8b6 commit 455d843
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37606,7 +37606,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

if (node.keywordToken === SyntaxKind.ImportKeyword) {
return checkImportMetaProperty(node);
if (node.name.escapedText === "defer") {
// 'checkGrammarMetaProperty' already reported the error for the standalone import.defer.
return errorType;
} else {
return checkImportMetaProperty(node);
}
}

return Debug.assertNever(node.keywordToken);
Expand Down Expand Up @@ -37650,7 +37655,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_node18_or_nodenext);
}
const file = getSourceFileOfNode(node);
Debug.assert(node.name.escapedText === "defer" || !!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag.");
Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag.");
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
}

Expand Down

0 comments on commit 455d843

Please sign in to comment.