mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-06 04:35:21 -05:00
Provide an error when using 'import.meta' without setting 'esnext'.
This commit is contained in:
@@ -18702,10 +18702,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (node.keywordToken === SyntaxKind.ImportKeyword) {
|
||||
const file = getSourceFileOfNode(node);
|
||||
Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag.");
|
||||
Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module.");
|
||||
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : unknownType;
|
||||
return checkImportMetaProperty(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18725,6 +18722,16 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkImportMetaProperty(node: MetaProperty) {
|
||||
if (languageVersion < ScriptTarget.ESNext && modulekind < ModuleKind.ESNext) {
|
||||
error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options);
|
||||
}
|
||||
const file = getSourceFileOfNode(node);
|
||||
Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag.");
|
||||
Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module.");
|
||||
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : unknownType;
|
||||
}
|
||||
|
||||
function getTypeOfParameter(symbol: Symbol) {
|
||||
const type = getTypeOfSymbol(symbol);
|
||||
if (strictNullChecks) {
|
||||
|
||||
@@ -967,6 +967,10 @@
|
||||
"category": "Error",
|
||||
"code": 1342
|
||||
},
|
||||
"The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.": {
|
||||
"category": "Error",
|
||||
"code": 1343
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
|
||||
Reference in New Issue
Block a user