mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add --module preserve, support require in --moduleResolution bundler (#56785)
This commit is contained in:
1 parent
458eae07d3
commit
6cb6fc94ae
173 files changed
+4719
-534
No files matched your search
@@ -282,7 +282,6 @@ import {
|
||||
setValueDeclaration,
|
||||
ShorthandPropertyAssignment,
|
||||
shouldPreserveConstEnums,
|
||||
shouldResolveJsRequire,
|
||||
SignatureDeclaration,
|
||||
skipParentheses,
|
||||
sliceAfter,
|
||||
@@ -3559,7 +3558,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
const possibleVariableDecl = node.kind === SyntaxKind.VariableDeclaration ? node : node.parent.parent;
|
||||
if (
|
||||
isInJSFile(node) &&
|
||||
shouldResolveJsRequire(options) &&
|
||||
isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
|
||||
!getJSDocTypeTag(node) &&
|
||||
!(getCombinedModifierFlags(node) & ModifierFlags.Export)
|
||||
|
||||
+26
-19
@@ -322,7 +322,6 @@ import {
|
||||
getLineAndCharacterOfPosition,
|
||||
getLocalSymbolForExportDefault,
|
||||
getMembersOfDeclaration,
|
||||
getModeForUsageLocation,
|
||||
getModifiers,
|
||||
getModuleInstanceState,
|
||||
getNameFromImportAttribute,
|
||||
@@ -960,7 +959,6 @@ import {
|
||||
ShorthandPropertyAssignment,
|
||||
shouldAllowImportingTsExtension,
|
||||
shouldPreserveConstEnums,
|
||||
shouldResolveJsRequire,
|
||||
Signature,
|
||||
SignatureDeclaration,
|
||||
SignatureFlags,
|
||||
@@ -4059,7 +4057,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
function getUsageModeForExpression(usage: Expression) {
|
||||
return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage) : undefined;
|
||||
return isStringLiteralLike(usage) ? host.getModeForUsageLocation(getSourceFileOfNode(usage), usage) : undefined;
|
||||
}
|
||||
|
||||
function isESMFormatImportImportingCommonjsFormatFile(usageMode: ResolutionMode, targetMode: ResolutionMode) {
|
||||
@@ -4073,7 +4071,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
|
||||
function canHaveSyntheticDefault(file: SourceFile | undefined, moduleSymbol: Symbol, dontResolveAlias: boolean, usage: Expression) {
|
||||
const usageMode = file && getUsageModeForExpression(usage);
|
||||
if (file && usageMode !== undefined) {
|
||||
if (file && usageMode !== undefined && ModuleKind.Node16 <= moduleKind && moduleKind <= ModuleKind.NodeNext) {
|
||||
const result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
||||
if (usageMode === ModuleKind.ESNext || result) {
|
||||
return result;
|
||||
@@ -5005,13 +5003,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
const currentSourceFile = getSourceFileOfNode(location);
|
||||
const contextSpecifier = isStringLiteralLike(location)
|
||||
? location
|
||||
: findAncestor(location, isImportCall)?.arguments[0] ||
|
||||
: (isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)?.name ||
|
||||
(isLiteralImportTypeNode(location) ? location : undefined)?.argument.literal ||
|
||||
(isVariableDeclaration(location) && location.initializer && isRequireCall(location.initializer, /*requireStringLiteralLikeArgument*/ true) ? location.initializer.arguments[0] : undefined) ||
|
||||
findAncestor(location, isImportCall)?.arguments[0] ||
|
||||
findAncestor(location, isImportDeclaration)?.moduleSpecifier ||
|
||||
findAncestor(location, isExternalModuleImportEqualsDeclaration)?.moduleReference.expression ||
|
||||
findAncestor(location, isExportDeclaration)?.moduleSpecifier ||
|
||||
(isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)?.name ||
|
||||
(isLiteralImportTypeNode(location) ? location : undefined)?.argument.literal;
|
||||
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
||||
findAncestor(location, isExportDeclaration)?.moduleSpecifier;
|
||||
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
||||
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
||||
const resolvedModule = host.getResolvedModule(currentSourceFile, moduleReference, mode)?.resolvedModule;
|
||||
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
|
||||
@@ -32083,7 +32082,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
const errorMessage = isClassic
|
||||
? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option
|
||||
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
|
||||
const mod = resolveExternalModule(location!, runtimeImportSpecifier, errorMessage, location!);
|
||||
// Synthesized JSX import is either first or after tslib
|
||||
const jsxImportIndex = compilerOptions.importHelpers ? 1 : 0;
|
||||
const specifier = file?.imports[jsxImportIndex];
|
||||
if (specifier) {
|
||||
Debug.assert(nodeIsSynthesized(specifier) && specifier.text === runtimeImportSpecifier, `Expected sourceFile.imports[${jsxImportIndex}] to be the synthesized JSX runtime import`);
|
||||
}
|
||||
const mod = resolveExternalModule(specifier || location!, runtimeImportSpecifier, errorMessage, location!);
|
||||
const result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : undefined;
|
||||
if (links) {
|
||||
links.jsxImplicitImportContainer = result || false;
|
||||
@@ -35811,7 +35816,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
// In JavaScript files, calls to any identifier 'require' are treated as external module imports
|
||||
if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
|
||||
if (isInJSFile(node) && isCommonJsRequire(node)) {
|
||||
return resolveExternalModuleTypeByLiteral(node.arguments![0] as StringLiteral);
|
||||
}
|
||||
|
||||
@@ -37745,6 +37750,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// fallthrough
|
||||
case ModuleKind.ES2022:
|
||||
case ModuleKind.ESNext:
|
||||
case ModuleKind.Preserve:
|
||||
case ModuleKind.System:
|
||||
if (languageVersion >= ScriptTarget.ES2017) {
|
||||
break;
|
||||
@@ -37752,8 +37758,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// fallthrough
|
||||
default:
|
||||
span ??= getSpanOfTokenAtPosition(sourceFile, node.pos);
|
||||
const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher :
|
||||
Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher;
|
||||
const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher :
|
||||
Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher;
|
||||
diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, message));
|
||||
hasError = true;
|
||||
break;
|
||||
@@ -46056,14 +46062,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
const mode = (moduleKind === ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
||||
if (mode !== ModuleKind.ESNext && moduleKind !== ModuleKind.ESNext) {
|
||||
if (mode !== ModuleKind.ESNext && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.Preserve) {
|
||||
const message = isImportAttributes
|
||||
? moduleKind === ModuleKind.NodeNext
|
||||
? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls
|
||||
: Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext
|
||||
: Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve
|
||||
: moduleKind === ModuleKind.NodeNext
|
||||
? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls
|
||||
: Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext;
|
||||
: Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve;
|
||||
return grammarErrorOnNode(node, message);
|
||||
}
|
||||
|
||||
@@ -46147,7 +46153,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (moduleKind >= ModuleKind.ES2015 && getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & NodeFlags.Ambient)) {
|
||||
if (moduleKind >= ModuleKind.ES2015 && moduleKind !== ModuleKind.Preserve && getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & NodeFlags.Ambient)) {
|
||||
// Import equals declaration is deprecated in es6 or above
|
||||
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
||||
}
|
||||
@@ -46433,6 +46439,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// Forbid export= in esm implementation files, and esm mode declaration files
|
||||
if (
|
||||
moduleKind >= ModuleKind.ES2015 &&
|
||||
moduleKind !== ModuleKind.Preserve &&
|
||||
((node.flags & NodeFlags.Ambient && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext) ||
|
||||
(!(node.flags & NodeFlags.Ambient) && getSourceFileOfNode(node).impliedNodeFormat !== ModuleKind.CommonJS))
|
||||
) {
|
||||
@@ -47605,7 +47612,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (
|
||||
(isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
|
||||
((node.parent.kind === SyntaxKind.ImportDeclaration || node.parent.kind === SyntaxKind.ExportDeclaration) && (node.parent as ImportDeclaration).moduleSpecifier === node) ||
|
||||
((isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler && isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false)) || isImportCall(node.parent)) ||
|
||||
((isInJSFile(node) && isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false)) || isImportCall(node.parent)) ||
|
||||
(isLiteralTypeNode(node.parent) && isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)
|
||||
) {
|
||||
return resolveExternalModuleName(node, node as LiteralExpression, ignoreErrors);
|
||||
@@ -50004,7 +50011,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// fallthrough
|
||||
default:
|
||||
diagnostics.add(
|
||||
createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher),
|
||||
createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher),
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -559,6 +559,7 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = {
|
||||
esnext: ModuleKind.ESNext,
|
||||
node16: ModuleKind.Node16,
|
||||
nodenext: ModuleKind.NodeNext,
|
||||
preserve: ModuleKind.Preserve,
|
||||
})),
|
||||
affectsSourceFile: true,
|
||||
affectsModuleResolution: true,
|
||||
|
||||
@@ -1220,7 +1220,7 @@
|
||||
"category": "Message",
|
||||
"code": 1377
|
||||
},
|
||||
"Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": {
|
||||
"Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.": {
|
||||
"category": "Error",
|
||||
"code": 1378
|
||||
},
|
||||
@@ -1424,7 +1424,7 @@
|
||||
"category": "Error",
|
||||
"code": 1431
|
||||
},
|
||||
"Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": {
|
||||
"Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.": {
|
||||
"category": "Error",
|
||||
"code": 1432
|
||||
},
|
||||
@@ -3595,7 +3595,7 @@
|
||||
"category": "Error",
|
||||
"code": 2820
|
||||
},
|
||||
"Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.": {
|
||||
"Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.": {
|
||||
"category": "Error",
|
||||
"code": 2821
|
||||
},
|
||||
@@ -3603,7 +3603,7 @@
|
||||
"category": "Error",
|
||||
"code": 2822
|
||||
},
|
||||
"Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.": {
|
||||
"Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.": {
|
||||
"category": "Error",
|
||||
"code": 2823
|
||||
},
|
||||
@@ -3683,7 +3683,7 @@
|
||||
"category": "Error",
|
||||
"code": 2853
|
||||
},
|
||||
"Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": {
|
||||
"Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.": {
|
||||
"category": "Error",
|
||||
"code": 2854
|
||||
},
|
||||
@@ -4309,7 +4309,7 @@
|
||||
"category": "Error",
|
||||
"code": 5070
|
||||
},
|
||||
"Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'.": {
|
||||
"Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'.": {
|
||||
"category": "Error",
|
||||
"code": 5071
|
||||
},
|
||||
@@ -4401,7 +4401,7 @@
|
||||
"category": "Error",
|
||||
"code": 5094
|
||||
},
|
||||
"Option '{0}' can only be used when 'module' is set to 'es2015' or later.": {
|
||||
"Option '{0}' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.": {
|
||||
"category": "Error",
|
||||
"code": 5095
|
||||
},
|
||||
|
||||
@@ -44,7 +44,6 @@ import {
|
||||
getCompilerOptionValue,
|
||||
getDirectoryPath,
|
||||
GetEffectiveTypeRootsHost,
|
||||
getEmitModuleKind,
|
||||
getEmitModuleResolutionKind,
|
||||
getNormalizedAbsolutePath,
|
||||
getOwnKeys,
|
||||
@@ -1417,20 +1416,7 @@ export function resolveModuleName(moduleName: string, containingFile: string, co
|
||||
else {
|
||||
let moduleResolution = compilerOptions.moduleResolution;
|
||||
if (moduleResolution === undefined) {
|
||||
switch (getEmitModuleKind(compilerOptions)) {
|
||||
case ModuleKind.CommonJS:
|
||||
moduleResolution = ModuleResolutionKind.Node10;
|
||||
break;
|
||||
case ModuleKind.Node16:
|
||||
moduleResolution = ModuleResolutionKind.Node16;
|
||||
break;
|
||||
case ModuleKind.NodeNext:
|
||||
moduleResolution = ModuleResolutionKind.NodeNext;
|
||||
break;
|
||||
default:
|
||||
moduleResolution = ModuleResolutionKind.Classic;
|
||||
break;
|
||||
}
|
||||
moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Module_resolution_kind_is_not_specified_using_0, ModuleResolutionKind[moduleResolution]);
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ function computeModuleSpecifiers(
|
||||
if (reason.kind !== FileIncludeKind.Import || reason.file !== importingSourceFile.path) return undefined;
|
||||
// If the candidate import mode doesn't match the mode we're generating for, don't consider it
|
||||
// TODO: maybe useful to keep around as an alternative option for certain contexts where the mode is overridable
|
||||
if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index)) return undefined;
|
||||
if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions)) return undefined;
|
||||
const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
|
||||
// If the preference is for non relative and the module specifier is relative, ignore it
|
||||
return preferences.relativePreference !== RelativePreference.NonRelative || !pathIsRelative(specifier) ?
|
||||
|
||||
+65
-37
@@ -140,6 +140,7 @@ import {
|
||||
getResolveJsonModule,
|
||||
getRootLength,
|
||||
getSetExternalModuleIndicator,
|
||||
getSourceFileOfNode,
|
||||
getSpellingSuggestion,
|
||||
getStrictOptionValue,
|
||||
getSupportedExtensions,
|
||||
@@ -287,7 +288,6 @@ import {
|
||||
ScriptTarget,
|
||||
setParent,
|
||||
setParentRecursive,
|
||||
shouldResolveJsRequire,
|
||||
skipTrivia,
|
||||
skipTypeChecking,
|
||||
some,
|
||||
@@ -852,20 +852,25 @@ export function getModeForFileReference(ref: FileReference | string, containingF
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
|
||||
* defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm).
|
||||
* If you have an actual import node, prefer using getModeForUsageLocation on the reference string node.
|
||||
* Use `program.getModeForResolutionAtIndex`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
|
||||
* Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
|
||||
* explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
|
||||
* `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
|
||||
* input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
|
||||
* `undefined`, as the result would have no impact on module resolution, emit, or type checking.
|
||||
* @param file File to fetch the resolution mode within
|
||||
* @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations
|
||||
* @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
|
||||
* should be the options of the referenced project, not the referencing project.
|
||||
*/
|
||||
export function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
|
||||
export function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
||||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ResolutionMode;
|
||||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ResolutionMode {
|
||||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions: CompilerOptions): ResolutionMode;
|
||||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions?: CompilerOptions): ResolutionMode {
|
||||
// we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup,
|
||||
// so it's safe to use them even pre-bind
|
||||
return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index));
|
||||
return getModeForUsageLocationWorker(file, getModuleNameStringLiteralAt(file, index), compilerOptions);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -880,15 +885,23 @@ export function isExclusivelyTypeOnlyImportOrExport(decl: ImportDeclaration | Ex
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
|
||||
* one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
|
||||
* Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
|
||||
* `moduleResolution` is `node16`+.
|
||||
* Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
|
||||
* Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
|
||||
* attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
|
||||
* depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
|
||||
* `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
|
||||
* impact on module resolution, emit, or type checking.
|
||||
* @param file The file the import or import-like reference is contained within
|
||||
* @param usage The module reference string
|
||||
* @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
|
||||
* should be the options of the referenced project, not the referencing project.
|
||||
* @returns The final resolution mode of the import
|
||||
*/
|
||||
export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike) {
|
||||
export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike, compilerOptions: CompilerOptions) {
|
||||
return getModeForUsageLocationWorker(file, usage, compilerOptions);
|
||||
}
|
||||
|
||||
function getModeForUsageLocationWorker(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike, compilerOptions?: CompilerOptions) {
|
||||
if ((isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent))) {
|
||||
const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
|
||||
if (isTypeOnly) {
|
||||
@@ -904,6 +917,11 @@ export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMo
|
||||
return override;
|
||||
}
|
||||
}
|
||||
if (compilerOptions && getEmitModuleKind(compilerOptions) === ModuleKind.Preserve) {
|
||||
return (usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(usage.parent, /*requireStringLiteralLikeArgument*/ false))
|
||||
? ModuleKind.CommonJS
|
||||
: ModuleKind.ESNext;
|
||||
}
|
||||
if (file.impliedNodeFormat === undefined) return undefined;
|
||||
if (file.impliedNodeFormat !== ModuleKind.ESNext) {
|
||||
// in cjs files, import call expressions are esm format, otherwise everything is cjs
|
||||
@@ -954,7 +972,7 @@ const emptyResolution: ResolvedModuleWithFailedLookupLocations & ResolvedTypeRef
|
||||
/** @internal */
|
||||
export interface ResolutionNameAndModeGetter<Entry, SourceFile> {
|
||||
getName(entry: Entry): string;
|
||||
getMode(entry: Entry, file: SourceFile): ResolutionMode;
|
||||
getMode(entry: Entry, file: SourceFile, compilerOptions: CompilerOptions): ResolutionMode;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -970,7 +988,7 @@ function getModuleResolutionName(literal: StringLiteralLike) {
|
||||
/** @internal */
|
||||
export const moduleResolutionNameAndModeGetter: ResolutionNameAndModeGetter<StringLiteralLike, SourceFile> = {
|
||||
getName: getModuleResolutionName,
|
||||
getMode: (entry, file) => getModeForUsageLocation(file, entry),
|
||||
getMode: (entry, file, compilerOptions) => getModeForUsageLocation(file, entry, compilerOptions),
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
@@ -1001,8 +1019,7 @@ function getTypeReferenceResolutionName<T extends FileReference | string>(entry:
|
||||
return !isString(entry) ? toFileNameLowerCase(entry.fileName) : entry;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const typeReferenceResolutionNameAndModeGetter: ResolutionNameAndModeGetter<FileReference | string, SourceFile | undefined> = {
|
||||
const typeReferenceResolutionNameAndModeGetter: ResolutionNameAndModeGetter<FileReference | string, SourceFile | undefined> = {
|
||||
getName: getTypeReferenceResolutionName,
|
||||
getMode: (entry, file) => getModeForFileReference(entry, file?.impliedNodeFormat),
|
||||
};
|
||||
@@ -1053,7 +1070,7 @@ export function loadWithModeAwareCache<Entry, SourceFile, ResolutionCache, Resol
|
||||
const loader = createLoader(containingFile, redirectedReference, options, host, resolutionCache);
|
||||
for (const entry of entries) {
|
||||
const name = loader.nameAndMode.getName(entry);
|
||||
const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
|
||||
const mode = loader.nameAndMode.getMode(entry, containingSourceFile, redirectedReference?.commandLine.options || options);
|
||||
const key = createModeAwareCacheKey(name, mode);
|
||||
let result = cache.get(key);
|
||||
if (!result) {
|
||||
@@ -1184,7 +1201,7 @@ export function getReferencedFileLocation(program: Program, ref: ReferencedFile)
|
||||
switch (kind) {
|
||||
case FileIncludeKind.Import:
|
||||
const importLiteral = getModuleNameStringLiteralAt(file, index);
|
||||
packageId = program.getResolvedModule(file, importLiteral.text, getModeForResolutionAtIndex(file, index))?.resolvedModule?.packageId;
|
||||
packageId = program.getResolvedModule(file, importLiteral.text, program.getModeForUsageLocation(file, importLiteral))?.resolvedModule?.packageId;
|
||||
if (importLiteral.pos === -1) return { file, packageId, text: importLiteral.text };
|
||||
pos = skipTrivia(file.text, importLiteral.pos);
|
||||
end = importLiteral.end;
|
||||
@@ -1885,6 +1902,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions,
|
||||
isSourceFileFromExternalLibrary,
|
||||
isSourceFileDefaultLibrary,
|
||||
getModeForUsageLocation,
|
||||
getModeForResolutionAtIndex,
|
||||
getSourceFileFromReference,
|
||||
getLibFileFromReference,
|
||||
sourceFileToPackageName,
|
||||
@@ -1894,6 +1913,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
resolvedTypeReferenceDirectiveNames,
|
||||
resolvedLibReferences,
|
||||
getResolvedModule,
|
||||
getResolvedModuleFromModuleSpecifier,
|
||||
getResolvedTypeReferenceDirective,
|
||||
forEachResolvedModule,
|
||||
forEachResolvedTypeReferenceDirective,
|
||||
@@ -1950,6 +1970,12 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
return resolvedModules?.get(file.path)?.get(moduleName, mode);
|
||||
}
|
||||
|
||||
function getResolvedModuleFromModuleSpecifier(moduleSpecifier: StringLiteralLike): ResolvedModuleWithFailedLookupLocations | undefined {
|
||||
const sourceFile = getSourceFileOfNode(moduleSpecifier);
|
||||
Debug.assertIsDefined(sourceFile, "`moduleSpecifier` must have a `SourceFile` ancestor. Use `program.getResolvedModule` instead to provide the containing file and resolution mode.");
|
||||
return getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier));
|
||||
}
|
||||
|
||||
function getResolvedTypeReferenceDirective(file: SourceFile, typeDirectiveName: string, mode: ResolutionMode) {
|
||||
return resolvedTypeReferenceDirectiveNames?.get(file.path)?.get(typeDirectiveName, mode);
|
||||
}
|
||||
@@ -2158,8 +2184,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
const moduleName = moduleNames[i];
|
||||
// If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
|
||||
if (file === oldSourceFile && !hasInvalidatedResolutions(file.path)) {
|
||||
const mode = getModeForUsageLocation(file, moduleName);
|
||||
const oldResolution = oldProgram?.getResolvedModule(file, moduleName.text, mode);
|
||||
const oldResolution = oldProgram?.getResolvedModule(file, moduleName.text, getModeForUsageLocation(file, moduleName));
|
||||
if (oldResolution?.resolvedModule) {
|
||||
if (isTraceEnabled(options, host)) {
|
||||
trace(
|
||||
@@ -2521,11 +2546,9 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
// ensure that module resolution results are still correct
|
||||
const resolutionsChanged = hasChangesInResolutions(
|
||||
moduleNames,
|
||||
newSourceFile,
|
||||
resolutions,
|
||||
(name, mode) => oldProgram!.getResolvedModule(newSourceFile, name, mode),
|
||||
name => oldProgram!.getResolvedModule(newSourceFile, name.text, getModeForUsageLocation(newSourceFile, name)),
|
||||
moduleResolutionIsEqualTo,
|
||||
moduleResolutionNameAndModeGetter,
|
||||
);
|
||||
if (resolutionsChanged) structureIsReused = StructureIsReused.SafeModules;
|
||||
const typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
||||
@@ -2534,11 +2557,9 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
// ensure that types resolutions are still correct
|
||||
const typeReferenceResolutionsChanged = hasChangesInResolutions(
|
||||
typesReferenceDirectives,
|
||||
newSourceFile,
|
||||
typeReferenceResolutions,
|
||||
(name, mode) => oldProgram?.getResolvedTypeReferenceDirective(newSourceFile, name, mode),
|
||||
name => oldProgram!.getResolvedTypeReferenceDirective(newSourceFile, getTypeReferenceResolutionName(name), getModeForFileReference(name, newSourceFile.impliedNodeFormat)),
|
||||
typeDirectiveIsEqualTo,
|
||||
typeReferenceResolutionNameAndModeGetter,
|
||||
);
|
||||
if (typeReferenceResolutionsChanged) structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
@@ -3345,8 +3366,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
collectModuleReferences(node, /*inAmbientModule*/ false);
|
||||
}
|
||||
|
||||
const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
|
||||
if ((file.flags & NodeFlags.PossiblyContainsDynamicImport) || shouldProcessRequires) {
|
||||
if ((file.flags & NodeFlags.PossiblyContainsDynamicImport) || isJavaScriptFile) {
|
||||
collectDynamicImportOrRequireCalls(file);
|
||||
}
|
||||
|
||||
@@ -3408,7 +3428,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
const r = /import|require/g;
|
||||
while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null
|
||||
const node = getNodeAtPosition(file, r.lastIndex);
|
||||
if (shouldProcessRequires && isRequireCall(node, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
if (isJavaScriptFile && isRequireCall(node, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
||||
imports = append(imports, node.arguments[0]);
|
||||
}
|
||||
@@ -4024,13 +4044,13 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
const resolutions = resolvedModulesProcessing?.get(file.path) ||
|
||||
resolveModuleNamesReusingOldState(moduleNames, file);
|
||||
Debug.assert(resolutions.length === moduleNames.length);
|
||||
const optionsForFile = (useSourceOfProjectReferenceRedirect ? getRedirectReferenceForResolution(file)?.commandLine.options : undefined) || options;
|
||||
const optionsForFile = getRedirectReferenceForResolution(file)?.commandLine.options || options;
|
||||
const resolutionsInFile = createModeAwareCache<ResolutionWithFailedLookupLocations>();
|
||||
(resolvedModules ??= new Map()).set(file.path, resolutionsInFile);
|
||||
for (let index = 0; index < moduleNames.length; index++) {
|
||||
const resolution = resolutions[index].resolvedModule;
|
||||
const moduleName = moduleNames[index].text;
|
||||
const mode = getModeForUsageLocation(file, moduleNames[index]);
|
||||
const mode = getModeForUsageLocationWorker(file, moduleNames[index], optionsForFile);
|
||||
resolutionsInFile.set(moduleName, mode, resolutions[index]);
|
||||
addResolutionDiagnosticsFromResolutionOrCache(file, moduleName, resolutions[index], mode);
|
||||
|
||||
@@ -4324,9 +4344,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Classic) {
|
||||
createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_when_moduleResolution_is_set_to_classic, "resolveJsonModule");
|
||||
}
|
||||
// Any emit other than common js, amd, es2015 or esnext is error
|
||||
else if (!hasJsonModuleEmitEnabled(options)) {
|
||||
createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module");
|
||||
createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_when_module_is_set_to_none_system_or_umd, "resolveJsonModule", "module");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4412,7 +4431,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
}
|
||||
|
||||
if (options.preserveValueImports && getEmitModuleKind(options) < ModuleKind.ES2015) {
|
||||
createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_es2015_or_later, "preserveValueImports");
|
||||
createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later, "preserveValueImports");
|
||||
}
|
||||
|
||||
const moduleKind = getEmitModuleKind(options);
|
||||
@@ -4443,8 +4462,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "customConditions");
|
||||
}
|
||||
|
||||
if (moduleResolution === ModuleResolutionKind.Bundler && !emitModuleKindIsNonNodeESM(moduleKind)) {
|
||||
createOptionValueDiagnostic("moduleResolution", Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_es2015_or_later, "bundler");
|
||||
if (moduleResolution === ModuleResolutionKind.Bundler && !emitModuleKindIsNonNodeESM(moduleKind) && moduleKind !== ModuleKind.Preserve) {
|
||||
createOptionValueDiagnostic("moduleResolution", Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later, "bundler");
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -4981,6 +5000,15 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
}
|
||||
return symlinks;
|
||||
}
|
||||
|
||||
function getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode {
|
||||
const optionsForFile = getRedirectReferenceForResolution(file)?.commandLine.options || options;
|
||||
return getModeForUsageLocationWorker(file, usage, optionsForFile);
|
||||
}
|
||||
|
||||
function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode {
|
||||
return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index));
|
||||
}
|
||||
}
|
||||
|
||||
interface HostForUseSourceOfProjectReferenceRedirect {
|
||||
|
||||
@@ -822,7 +822,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
|
||||
const seenNamesInFile = createModeAwareCache<true>();
|
||||
for (const entry of entries) {
|
||||
const name = loader.nameAndMode.getName(entry);
|
||||
const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
|
||||
const mode = loader.nameAndMode.getMode(entry, containingSourceFile, redirectedReference?.commandLine.options || options);
|
||||
let resolution = resolutionsInFile.get(name, mode);
|
||||
// Resolution is valid if it is present and not invalidated
|
||||
if (
|
||||
@@ -881,7 +881,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
|
||||
reusedNames?.forEach(entry =>
|
||||
seenNamesInFile.set(
|
||||
loader.nameAndMode.getName(entry),
|
||||
loader.nameAndMode.getMode(entry, containingSourceFile),
|
||||
loader.nameAndMode.getMode(entry, containingSourceFile, redirectedReference?.commandLine.options || options),
|
||||
true,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -82,6 +82,7 @@ function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory<Source
|
||||
case ModuleKind.ES2022:
|
||||
case ModuleKind.ES2020:
|
||||
case ModuleKind.ES2015:
|
||||
case ModuleKind.Preserve:
|
||||
return transformECMAScriptModule;
|
||||
case ModuleKind.System:
|
||||
return transformSystemModule;
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
ExportAssignment,
|
||||
ExportDeclaration,
|
||||
Expression,
|
||||
ExpressionStatement,
|
||||
GeneratedIdentifierFlags,
|
||||
getEmitFlags,
|
||||
getEmitModuleKind,
|
||||
@@ -88,7 +89,7 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S
|
||||
setTextRange(factory.createNodeArray(insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements),
|
||||
);
|
||||
}
|
||||
if (!isExternalModule(node) || some(result.statements, isExternalModuleIndicator)) {
|
||||
if (!isExternalModule(node) || getEmitModuleKind(compilerOptions) === ModuleKind.Preserve || some(result.statements, isExternalModuleIndicator)) {
|
||||
return result;
|
||||
}
|
||||
return factory.updateSourceFile(
|
||||
@@ -146,6 +147,9 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S
|
||||
if (moduleName) {
|
||||
args.push(moduleName);
|
||||
}
|
||||
if (getEmitModuleKind(compilerOptions) === ModuleKind.Preserve) {
|
||||
return factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, args);
|
||||
}
|
||||
|
||||
if (!importRequireStatements) {
|
||||
const createRequireName = factory.createUniqueName("_createRequire", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel);
|
||||
@@ -238,9 +242,27 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S
|
||||
return statements;
|
||||
}
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): VisitResult<ExportAssignment | undefined> {
|
||||
// Elide `export=` as it is not legal with --module ES6
|
||||
return node.isExportEquals ? undefined : node;
|
||||
function visitExportAssignment(node: ExportAssignment): VisitResult<ExportAssignment | ExpressionStatement | undefined> {
|
||||
if (node.isExportEquals) {
|
||||
if (getEmitModuleKind(compilerOptions) === ModuleKind.Preserve) {
|
||||
const statement = setOriginalNode(
|
||||
factory.createExpressionStatement(
|
||||
factory.createAssignment(
|
||||
factory.createPropertyAccessExpression(
|
||||
factory.createIdentifier("module"),
|
||||
"exports",
|
||||
),
|
||||
node.expression,
|
||||
),
|
||||
),
|
||||
node,
|
||||
);
|
||||
return statement;
|
||||
}
|
||||
// Elide `export=` as it is not legal with --module ES6
|
||||
return undefined;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitExportDeclaration(node: ExportDeclaration) {
|
||||
|
||||
@@ -4698,6 +4698,8 @@ export interface Program extends ScriptReferenceHost {
|
||||
/** @internal */
|
||||
getResolvedModule(f: SourceFile, moduleName: string, mode: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined;
|
||||
/** @internal */
|
||||
getResolvedModuleFromModuleSpecifier(moduleSpecifier: StringLiteralLike): ResolvedModuleWithFailedLookupLocations | undefined;
|
||||
/** @internal */
|
||||
getResolvedTypeReferenceDirective(f: SourceFile, typeDirectiveName: string, mode: ResolutionMode): ResolvedTypeReferenceDirectiveWithFailedLookupLocations | undefined;
|
||||
/** @internal */
|
||||
forEachResolvedModule(
|
||||
@@ -4760,6 +4762,22 @@ export interface Program extends ScriptReferenceHost {
|
||||
/** @internal */ getAutomaticTypeDirectiveResolutions(): ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>;
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
isSourceFileDefaultLibrary(file: SourceFile): boolean;
|
||||
/**
|
||||
* Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
|
||||
* attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
|
||||
* depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
|
||||
* `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
|
||||
* impact on module resolution, emit, or type checking.
|
||||
*/
|
||||
getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
||||
/**
|
||||
* Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
|
||||
* explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
|
||||
* `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
|
||||
* input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
|
||||
* `undefined`, as the result would have no impact on module resolution, emit, or type checking.
|
||||
*/
|
||||
getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
|
||||
|
||||
// For testing purposes only.
|
||||
// This is set on created program to let us know how the program was created using old program
|
||||
@@ -4925,6 +4943,7 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost {
|
||||
getResolvedTypeReferenceDirectives(): ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>;
|
||||
getProjectReferenceRedirect(fileName: string): string | undefined;
|
||||
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
||||
getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
||||
|
||||
getResolvedModule(f: SourceFile, moduleName: string, mode: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined;
|
||||
|
||||
@@ -7296,6 +7315,9 @@ export enum ModuleKind {
|
||||
// Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext
|
||||
Node16 = 100,
|
||||
NodeNext = 199,
|
||||
|
||||
// Emit as written
|
||||
Preserve = 200,
|
||||
}
|
||||
|
||||
export const enum JsxEmit {
|
||||
|
||||
+12
-24
@@ -469,7 +469,6 @@ import {
|
||||
RequireOrImportCall,
|
||||
RequireVariableStatement,
|
||||
ResolutionMode,
|
||||
ResolutionNameAndModeGetter,
|
||||
ResolvedModuleFull,
|
||||
ResolvedModuleWithFailedLookupLocations,
|
||||
ResolvedTypeReferenceDirective,
|
||||
@@ -837,20 +836,16 @@ export function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirec
|
||||
/** @internal */
|
||||
export function hasChangesInResolutions<K, V>(
|
||||
names: readonly K[],
|
||||
newSourceFile: SourceFile,
|
||||
newResolutions: readonly V[],
|
||||
getOldResolution: (name: string, mode: ResolutionMode) => V | undefined,
|
||||
getOldResolution: (name: K) => V | undefined,
|
||||
comparer: (oldResolution: V, newResolution: V) => boolean,
|
||||
nameAndModeGetter: ResolutionNameAndModeGetter<K, SourceFile>,
|
||||
): boolean {
|
||||
Debug.assert(names.length === newResolutions.length);
|
||||
|
||||
for (let i = 0; i < names.length; i++) {
|
||||
const newResolution = newResolutions[i];
|
||||
const entry = names[i];
|
||||
const name = nameAndModeGetter.getName(entry);
|
||||
const mode = nameAndModeGetter.getMode(entry, newSourceFile);
|
||||
const oldResolution = getOldResolution(name, mode);
|
||||
const oldResolution = getOldResolution(entry);
|
||||
const changed = oldResolution
|
||||
? !newResolution || !comparer(oldResolution, newResolution)
|
||||
: newResolution;
|
||||
@@ -8655,6 +8650,9 @@ export const computedOptions = createComputedCompilerOptions({
|
||||
case ModuleKind.NodeNext:
|
||||
moduleResolution = ModuleResolutionKind.NodeNext;
|
||||
break;
|
||||
case ModuleKind.Preserve:
|
||||
moduleResolution = ModuleResolutionKind.Bundler;
|
||||
break;
|
||||
default:
|
||||
moduleResolution = ModuleResolutionKind.Classic;
|
||||
break;
|
||||
@@ -8686,6 +8684,7 @@ export const computedOptions = createComputedCompilerOptions({
|
||||
switch (computedOptions.module.computeValue(compilerOptions)) {
|
||||
case ModuleKind.Node16:
|
||||
case ModuleKind.NodeNext:
|
||||
case ModuleKind.Preserve:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -8878,18 +8877,12 @@ export function emitModuleKindIsNonNodeESM(moduleKind: ModuleKind) {
|
||||
/** @internal */
|
||||
export function hasJsonModuleEmitEnabled(options: CompilerOptions) {
|
||||
switch (getEmitModuleKind(options)) {
|
||||
case ModuleKind.CommonJS:
|
||||
case ModuleKind.AMD:
|
||||
case ModuleKind.ES2015:
|
||||
case ModuleKind.ES2020:
|
||||
case ModuleKind.ES2022:
|
||||
case ModuleKind.ESNext:
|
||||
case ModuleKind.Node16:
|
||||
case ModuleKind.NodeNext:
|
||||
return true;
|
||||
default:
|
||||
case ModuleKind.None:
|
||||
case ModuleKind.System:
|
||||
case ModuleKind.UMD:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -8913,12 +8906,6 @@ export function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResol
|
||||
|| moduleResolution === ModuleResolutionKind.Bundler;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function shouldResolveJsRequire(compilerOptions: CompilerOptions): boolean {
|
||||
// `bundler` doesn't support resolving `require`, but needs to in `noDtsResolution` to support Find Source Definition
|
||||
return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export type StrictOptionName =
|
||||
| "noImplicitAny"
|
||||
@@ -9595,7 +9582,8 @@ export function usesExtensionsOnImports({ imports }: SourceFile, hasExtension: (
|
||||
|
||||
/** @internal */
|
||||
export function getModuleSpecifierEndingPreference(preference: UserPreferences["importModuleSpecifierEnding"], resolutionMode: ResolutionMode, compilerOptions: CompilerOptions, sourceFile: SourceFile): ModuleSpecifierEnding {
|
||||
if (preference === "js" || resolutionMode === ModuleKind.ESNext) {
|
||||
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
||||
if (preference === "js" || resolutionMode === ModuleKind.ESNext && ModuleResolutionKind.Node16 <= moduleResolution && moduleResolution <= ModuleResolutionKind.NodeNext) {
|
||||
// Extensions are explicitly requested or required. Now choose between .js and .ts.
|
||||
if (!shouldAllowImportingTsExtension(compilerOptions)) {
|
||||
return ModuleSpecifierEnding.JsExtension;
|
||||
|
||||
@@ -3751,11 +3751,19 @@ export const enum ModuleKind {
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
ESNext = "ESNext",
|
||||
Node16 = "Node16",
|
||||
NodeNext = "NodeNext",
|
||||
Preserve = "Preserve",
|
||||
}
|
||||
|
||||
export const enum ModuleResolutionKind {
|
||||
Classic = "Classic",
|
||||
/** @deprecated Renamed to `Node10` */
|
||||
Node = "Node",
|
||||
Node10 = "Node10",
|
||||
Node16 = "Node16",
|
||||
NodeNext = "NodeNext",
|
||||
Bundler = "Bundler",
|
||||
}
|
||||
|
||||
export const enum NewLineKind {
|
||||
|
||||
@@ -26,7 +26,6 @@ import {
|
||||
FunctionDeclaration,
|
||||
FunctionExpression,
|
||||
getEmitScriptTarget,
|
||||
getModeForUsageLocation,
|
||||
getQuotePreference,
|
||||
getSynthesizedDeepClone,
|
||||
getSynthesizedDeepClones,
|
||||
@@ -107,7 +106,7 @@ function fixImportOfModuleExports(
|
||||
quotePreference: QuotePreference,
|
||||
) {
|
||||
for (const moduleSpecifier of importingFile.imports) {
|
||||
const imported = program.getResolvedModule(importingFile, moduleSpecifier.text, getModeForUsageLocation(importingFile, moduleSpecifier))?.resolvedModule;
|
||||
const imported = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)?.resolvedModule;
|
||||
if (!imported || imported.resolvedFileName !== exportingFile.fileName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -116,10 +116,10 @@ function getInfo(sourceFile: SourceFile, pos: number, program: Program): Info |
|
||||
const importDeclaration = findAncestor(token, isImportDeclaration);
|
||||
if (importDeclaration === undefined) return undefined;
|
||||
|
||||
const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
|
||||
const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier : undefined;
|
||||
if (moduleSpecifier === undefined) return undefined;
|
||||
|
||||
const resolvedModule = program.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined)?.resolvedModule;
|
||||
const resolvedModule = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)?.resolvedModule;
|
||||
if (resolvedModule === undefined) return undefined;
|
||||
|
||||
const moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
||||
@@ -136,7 +136,7 @@ function getInfo(sourceFile: SourceFile, pos: number, program: Program): Info |
|
||||
if (node === undefined) return undefined;
|
||||
|
||||
const exportName = { node: token, isTypeOnly: isTypeDeclaration(node) };
|
||||
return { exportName, node, moduleSourceFile, moduleSpecifier };
|
||||
return { exportName, node, moduleSourceFile, moduleSpecifier: moduleSpecifier.text };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ import {
|
||||
|
||||
registerCodeFix({
|
||||
errorCodes: [
|
||||
Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
|
||||
Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
|
||||
Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
|
||||
Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code,
|
||||
Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code,
|
||||
Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code,
|
||||
],
|
||||
getCodeActions: function getCodeActionsToFixModuleAndTarget(context) {
|
||||
const compilerOptions = context.program.getCompilerOptions();
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
getEffectiveBaseTypeNode,
|
||||
getEmitScriptTarget,
|
||||
getMeaningFromLocation,
|
||||
getModeForUsageLocation,
|
||||
getTextOfNode,
|
||||
getTokenAtPosition,
|
||||
hasOverrideModifier,
|
||||
@@ -119,7 +118,7 @@ function getInfo(sourceFile: SourceFile, pos: number, context: CodeFixContextBas
|
||||
else if (isImportSpecifier(parent) && parent.name === node) {
|
||||
Debug.assertNode(node, isIdentifier, "Expected an identifier for spelling (import)");
|
||||
const importDeclaration = findAncestor(node, isImportDeclaration)!;
|
||||
const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration);
|
||||
const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(context, importDeclaration);
|
||||
if (resolvedSourceFile && resolvedSourceFile.symbol) {
|
||||
suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(node, resolvedSourceFile.symbol);
|
||||
}
|
||||
@@ -178,10 +177,10 @@ function convertSemanticMeaningToSymbolFlags(meaning: SemanticMeaning): SymbolFl
|
||||
return flags;
|
||||
}
|
||||
|
||||
function getResolvedSourceFileFromImportDeclaration(sourceFile: SourceFile, context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined {
|
||||
function getResolvedSourceFileFromImportDeclaration(context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined {
|
||||
if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier)) return undefined;
|
||||
|
||||
const resolvedModule = context.program.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text, getModeForUsageLocation(sourceFile, importDeclaration.moduleSpecifier))?.resolvedModule;
|
||||
const resolvedModule = context.program.getResolvedModuleFromModuleSpecifier(importDeclaration.moduleSpecifier)?.resolvedModule;
|
||||
if (!resolvedModule) return undefined;
|
||||
|
||||
return context.program.getSourceFile(resolvedModule.resolvedFileName);
|
||||
|
||||
@@ -44,7 +44,6 @@ import {
|
||||
getExportInfoMap,
|
||||
getMeaningFromDeclaration,
|
||||
getMeaningFromLocation,
|
||||
getModeForUsageLocation,
|
||||
getNameForExportedSymbol,
|
||||
getNodeId,
|
||||
getOutputExtension,
|
||||
@@ -1160,6 +1159,7 @@ function getUmdImportKind(importingFile: SourceFile, compilerOptions: CompilerOp
|
||||
case ModuleKind.ES2022:
|
||||
case ModuleKind.ESNext:
|
||||
case ModuleKind.None:
|
||||
case ModuleKind.Preserve:
|
||||
// Fall back to the `import * as ns` style import.
|
||||
return ImportKind.Namespace;
|
||||
case ModuleKind.Node16:
|
||||
@@ -1440,7 +1440,7 @@ function promoteFromTypeOnly(
|
||||
// Change .ts extension to .js if necessary
|
||||
if (!compilerOptions.allowImportingTsExtensions) {
|
||||
const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importClause.parent);
|
||||
const resolvedModule = moduleSpecifier && program.getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier))?.resolvedModule;
|
||||
const resolvedModule = moduleSpecifier && program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)?.resolvedModule;
|
||||
if (resolvedModule?.resolvedUsingTsExtension) {
|
||||
const changedExtension = changeAnyExtension(moduleSpecifier!.text, getOutputExtension(moduleSpecifier!.text, compilerOptions));
|
||||
changes.replaceNode(sourceFile, moduleSpecifier!, factory.createStringLiteral(changedExtension));
|
||||
|
||||
@@ -2807,7 +2807,7 @@ export function getCompletionEntryDetails(
|
||||
|
||||
const { previousToken, contextToken } = getRelevantTokens(position, sourceFile);
|
||||
if (isInString(sourceFile, position, previousToken)) {
|
||||
return StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
|
||||
return StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, program, host, cancellationToken, preferences);
|
||||
}
|
||||
|
||||
// Compute all the completion symbols again.
|
||||
|
||||
@@ -65,7 +65,6 @@ import {
|
||||
getLocalSymbolForExportDefault,
|
||||
getMeaningFromDeclaration,
|
||||
getMeaningFromLocation,
|
||||
getModeForUsageLocation,
|
||||
getNameOfDeclaration,
|
||||
getNameTable,
|
||||
getNextJSDocCommentLocation,
|
||||
@@ -1023,7 +1022,7 @@ export namespace Core {
|
||||
if (!options.implementations && isStringLiteralLike(node)) {
|
||||
if (isModuleSpecifierLike(node)) {
|
||||
const fileIncludeReasons = program.getFileIncludeReasons();
|
||||
const referencedFileName = program.getResolvedModule(node.getSourceFile(), node.text, getModeForUsageLocation(node.getSourceFile(), node))?.resolvedModule?.resolvedFileName;
|
||||
const referencedFileName = program.getResolvedModuleFromModuleSpecifier(node)?.resolvedModule?.resolvedFileName;
|
||||
const referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined;
|
||||
if (referencedFile) {
|
||||
return [{ definition: { type: DefinitionKind.String, node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || emptyArray }];
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
GetCanonicalFileName,
|
||||
getDirectoryPath,
|
||||
getFileMatcherPatterns,
|
||||
getModeForUsageLocation,
|
||||
getOptionFromName,
|
||||
getRegexFromPattern,
|
||||
getRelativePathFromDirectory,
|
||||
@@ -246,9 +245,9 @@ function getSourceFileToImport(
|
||||
return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true };
|
||||
}
|
||||
else {
|
||||
const mode = getModeForUsageLocation(importingSourceFile, importLiteral);
|
||||
const mode = program.getModeForUsageLocation(importingSourceFile, importLiteral);
|
||||
const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ?
|
||||
program.getResolvedModule(importingSourceFile, importLiteral.text, mode) :
|
||||
program.getResolvedModuleFromModuleSpecifier(importLiteral) :
|
||||
host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
|
||||
return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles());
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import {
|
||||
getDirectoryPath,
|
||||
getEffectiveBaseTypeNode,
|
||||
getInvokedExpression,
|
||||
getModeForUsageLocation,
|
||||
getNameFromPropertyName,
|
||||
getNameOfDeclaration,
|
||||
getObjectFlags,
|
||||
@@ -203,7 +202,7 @@ export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile
|
||||
if (!symbol && isModuleSpecifierLike(fallbackNode)) {
|
||||
// We couldn't resolve the module specifier as an external module, but it could
|
||||
// be that module resolution succeeded but the target was not a module.
|
||||
const ref = program.getResolvedModule(sourceFile, fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode))?.resolvedModule;
|
||||
const ref = program.getResolvedModuleFromModuleSpecifier(fallbackNode)?.resolvedModule;
|
||||
if (ref) {
|
||||
return [{
|
||||
name: fallbackNode.text,
|
||||
@@ -359,7 +358,7 @@ export function getReferenceAtPosition(sourceFile: SourceFile, position: number,
|
||||
if (sourceFile.imports.length || sourceFile.moduleAugmentations.length) {
|
||||
const node = getTouchingToken(sourceFile, position);
|
||||
let resolution: ResolvedModuleWithFailedLookupLocations | undefined;
|
||||
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModule(sourceFile, node.text, getModeForUsageLocation(sourceFile, node)))) {
|
||||
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModuleFromModuleSpecifier(node))) {
|
||||
const verifiedFileName = resolution.resolvedModule?.resolvedFileName;
|
||||
const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text);
|
||||
return {
|
||||
|
||||
@@ -51,7 +51,6 @@ import {
|
||||
getDecorators,
|
||||
getDirectoryPath,
|
||||
getLocaleSpecificMessage,
|
||||
getModeForUsageLocation,
|
||||
getModifiers,
|
||||
getPropertySymbolFromBindingElement,
|
||||
getQuotePreference,
|
||||
@@ -313,10 +312,11 @@ function getTargetFileImportsAndAddExportInOldFile(
|
||||
forEachImportInStatement(oldStatement, i => {
|
||||
// Recomputing module specifier
|
||||
const moduleSpecifier = moduleSpecifierFromImport(i);
|
||||
const resolved = program.getResolvedModule(oldFile, moduleSpecifier.text, getModeForUsageLocation(oldFile, moduleSpecifier));
|
||||
const compilerOptions = program.getCompilerOptions();
|
||||
const resolved = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier);
|
||||
const fileName = resolved?.resolvedModule?.resolvedFileName;
|
||||
if (fileName && targetSourceFile) {
|
||||
const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), targetSourceFile, targetSourceFile.fileName, fileName, createModuleSpecifierResolutionHost(program, host));
|
||||
const newModuleSpecifier = getModuleSpecifier(compilerOptions, targetSourceFile, targetSourceFile.fileName, fileName, createModuleSpecifierResolutionHost(program, host));
|
||||
append(copiedOldImports, filterImport(i, makeStringLiteral(newModuleSpecifier, quotePreference), name => importsToCopy.has(checker.getSymbolAtLocation(name)!)));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -52,7 +52,6 @@ import {
|
||||
getEffectiveTypeRoots,
|
||||
getEmitModuleResolutionKind,
|
||||
getLeadingCommentRanges,
|
||||
getModeForUsageLocation,
|
||||
getModuleSpecifierEndingPreference,
|
||||
getOwnKeys,
|
||||
getPackageJsonTypesVersionsPaths,
|
||||
@@ -203,7 +202,7 @@ export function getStringLiteralCompletions(
|
||||
}
|
||||
if (isInString(sourceFile, position, contextToken)) {
|
||||
if (!contextToken || !isStringLiteralLike(contextToken)) return undefined;
|
||||
const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program.getTypeChecker(), options, host, preferences);
|
||||
const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program, host, preferences);
|
||||
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences, position, includeSymbol);
|
||||
}
|
||||
}
|
||||
@@ -281,10 +280,10 @@ function convertStringLiteralCompletions(
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getStringLiteralCompletionDetails(name: string, sourceFile: SourceFile, position: number, contextToken: Node | undefined, checker: TypeChecker, options: CompilerOptions, host: LanguageServiceHost, cancellationToken: CancellationToken, preferences: UserPreferences) {
|
||||
export function getStringLiteralCompletionDetails(name: string, sourceFile: SourceFile, position: number, contextToken: Node | undefined, program: Program, host: LanguageServiceHost, cancellationToken: CancellationToken, preferences: UserPreferences) {
|
||||
if (!contextToken || !isStringLiteralLike(contextToken)) return undefined;
|
||||
const completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences);
|
||||
return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken);
|
||||
const completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program, host, preferences);
|
||||
return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, program.getTypeChecker(), cancellationToken);
|
||||
}
|
||||
|
||||
function stringLiteralCompletionDetails(name: string, location: Node, completion: StringLiteralCompletion, sourceFile: SourceFile, checker: TypeChecker, cancellationToken: CancellationToken): CompletionEntryDetails | undefined {
|
||||
@@ -361,13 +360,14 @@ interface StringLiteralCompletionsFromTypes {
|
||||
readonly isNewIdentifier: boolean;
|
||||
}
|
||||
type StringLiteralCompletion = { readonly kind: StringLiteralCompletionKind.Paths; readonly paths: readonly PathCompletion[]; } | StringLiteralCompletionsFromProperties | StringLiteralCompletionsFromTypes;
|
||||
function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringLiteralLike, position: number, typeChecker: TypeChecker, compilerOptions: CompilerOptions, host: LanguageServiceHost, preferences: UserPreferences): StringLiteralCompletion | undefined {
|
||||
function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringLiteralLike, position: number, program: Program, host: LanguageServiceHost, preferences: UserPreferences): StringLiteralCompletion | undefined {
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const parent = walkUpParentheses(node.parent);
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.LiteralType: {
|
||||
const grandParent = walkUpParentheses(parent.parent);
|
||||
if (grandParent.kind === SyntaxKind.ImportType) {
|
||||
return { kind: StringLiteralCompletionKind.Paths, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
|
||||
return { kind: StringLiteralCompletionKind.Paths, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, program, host, preferences) };
|
||||
}
|
||||
return fromUnionableLiteralType(grandParent);
|
||||
}
|
||||
@@ -424,7 +424,7 @@ function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringL
|
||||
// import x = require("/*completion position*/");
|
||||
// var y = require("/*completion position*/");
|
||||
// export * from "/*completion position*/";
|
||||
return { kind: StringLiteralCompletionKind.Paths, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
|
||||
return { kind: StringLiteralCompletionKind.Paths, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, program, host, preferences) };
|
||||
case SyntaxKind.CaseClause:
|
||||
const tracker = newCaseClauseTracker(typeChecker, (parent as CaseClause).parent.clauses);
|
||||
const contextualTypes = fromContextualType();
|
||||
@@ -577,16 +577,18 @@ function addReplacementSpans(text: string, textStart: number, names: readonly Na
|
||||
return names.map(({ name, kind, extension }): PathCompletion => (name.includes(directorySeparator) || name.includes(altDirectorySeparator)) ? { name, kind, extension, span: wholeSpan } : { name, kind, extension, span });
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionsFromModuleNames(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker, preferences: UserPreferences): readonly PathCompletion[] {
|
||||
return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences));
|
||||
function getStringLiteralCompletionsFromModuleNames(sourceFile: SourceFile, node: LiteralExpression, program: Program, host: LanguageServiceHost, preferences: UserPreferences): readonly PathCompletion[] {
|
||||
return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, program, host, preferences));
|
||||
}
|
||||
|
||||
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker, preferences: UserPreferences): readonly NameAndKind[] {
|
||||
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile, node: LiteralExpression, program: Program, host: LanguageServiceHost, preferences: UserPreferences): readonly NameAndKind[] {
|
||||
const literalValue = normalizeSlashes(node.text);
|
||||
const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : undefined;
|
||||
const mode = isStringLiteralLike(node) ? program.getModeForUsageLocation(sourceFile, node) : undefined;
|
||||
|
||||
const scriptPath = sourceFile.path;
|
||||
const scriptDirectory = getDirectoryPath(scriptPath);
|
||||
const compilerOptions = program.getCompilerOptions();
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const extensionOptions = getExtensionOptions(compilerOptions, ReferenceKind.ModuleSpecifier, sourceFile, typeChecker, preferences, mode);
|
||||
|
||||
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue))
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
getAllowSyntheticDefaultImports,
|
||||
getAssignmentDeclarationKind,
|
||||
getFunctionFlags,
|
||||
getModeForUsageLocation,
|
||||
hasInitializer,
|
||||
hasPropertyAccessExpressionWithName,
|
||||
Identifier,
|
||||
@@ -88,7 +87,7 @@ export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Pr
|
||||
const importNode = importFromModuleSpecifier(moduleSpecifier);
|
||||
const name = importNameForConvertToDefaultImport(importNode);
|
||||
if (!name) continue;
|
||||
const module = program.getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier))?.resolvedModule;
|
||||
const module = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)?.resolvedModule;
|
||||
const resolvedFile = module && program.getSourceFile(module.resolvedFileName);
|
||||
if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
|
||||
diags.push(createDiagnosticForNode(name, Diagnostics.Import_may_be_converted_to_a_default_import));
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
/c.ts(1,16): error TS2307: Cannot find module './thisfiledoesnotexist.ts' or its corresponding type declarations.
|
||||
|
||||
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
==== /ts.ts (0 errors) ====
|
||||
export {};
|
||||
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/compiler/ambientRequireFunction.ts] ////
|
||||
|
||||
//// [node.d.ts]
|
||||
declare function require(moduleName: string): any;
|
||||
|
||||
declare module "fs" {
|
||||
export function readFileSync(s: string): string;
|
||||
}
|
||||
|
||||
//// [app.js]
|
||||
/// <reference path="node.d.ts"/>
|
||||
|
||||
const fs = require("fs");
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
|
||||
//// [app.js]
|
||||
/// <reference path="node.d.ts"/>
|
||||
var fs = require("fs");
|
||||
var text = fs.readFileSync("/a/b/c");
|
||||
@@ -0,0 +1,29 @@
|
||||
//// [tests/cases/compiler/ambientRequireFunction.ts] ////
|
||||
|
||||
=== app.js ===
|
||||
/// <reference path="node.d.ts"/>
|
||||
|
||||
const fs = require("fs");
|
||||
>fs : Symbol(fs, Decl(app.js, 2, 5))
|
||||
>require : Symbol(require, Decl(node.d.ts, 0, 0))
|
||||
>"fs" : Symbol(fs, Decl(node.d.ts, 0, 50))
|
||||
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
>text : Symbol(text, Decl(app.js, 3, 5))
|
||||
>fs.readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21))
|
||||
>fs : Symbol(fs, Decl(app.js, 2, 5))
|
||||
>readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21))
|
||||
|
||||
=== node.d.ts ===
|
||||
declare function require(moduleName: string): any;
|
||||
>require : Symbol(require, Decl(node.d.ts, 0, 0))
|
||||
>moduleName : Symbol(moduleName, Decl(node.d.ts, 0, 25))
|
||||
|
||||
declare module "fs" {
|
||||
>"fs" : Symbol("fs", Decl(node.d.ts, 0, 50))
|
||||
|
||||
export function readFileSync(s: string): string;
|
||||
>readFileSync : Symbol(readFileSync, Decl(node.d.ts, 2, 21))
|
||||
>s : Symbol(s, Decl(node.d.ts, 3, 33))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//// [tests/cases/compiler/ambientRequireFunction.ts] ////
|
||||
|
||||
=== app.js ===
|
||||
/// <reference path="node.d.ts"/>
|
||||
|
||||
const fs = require("fs");
|
||||
>fs : typeof fs
|
||||
>require("fs") : typeof fs
|
||||
>require : (moduleName: string) => any
|
||||
>"fs" : "fs"
|
||||
|
||||
const text = fs.readFileSync("/a/b/c");
|
||||
>text : string
|
||||
>fs.readFileSync("/a/b/c") : string
|
||||
>fs.readFileSync : (s: string) => string
|
||||
>fs : typeof fs
|
||||
>readFileSync : (s: string) => string
|
||||
>"/a/b/c" : "/a/b/c"
|
||||
|
||||
=== node.d.ts ===
|
||||
declare function require(moduleName: string): any;
|
||||
>require : (moduleName: string) => any
|
||||
>moduleName : string
|
||||
|
||||
declare module "fs" {
|
||||
>"fs" : typeof import("fs")
|
||||
|
||||
export function readFileSync(s: string): string;
|
||||
>readFileSync : (s: string) => string
|
||||
>s : string
|
||||
}
|
||||
|
||||
+49
-11
@@ -3036,10 +3036,18 @@ declare namespace ts {
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
ESNext = "ESNext",
|
||||
Node16 = "Node16",
|
||||
NodeNext = "NodeNext",
|
||||
Preserve = "Preserve",
|
||||
}
|
||||
enum ModuleResolutionKind {
|
||||
Classic = "Classic",
|
||||
/** @deprecated Renamed to `Node10` */
|
||||
Node = "Node",
|
||||
Node10 = "Node10",
|
||||
Node16 = "Node16",
|
||||
NodeNext = "NodeNext",
|
||||
Bundler = "Bundler",
|
||||
}
|
||||
enum NewLineKind {
|
||||
Crlf = "Crlf",
|
||||
@@ -6660,6 +6668,22 @@ declare namespace ts {
|
||||
};
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
isSourceFileDefaultLibrary(file: SourceFile): boolean;
|
||||
/**
|
||||
* Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
|
||||
* attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
|
||||
* depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
|
||||
* `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
|
||||
* impact on module resolution, emit, or type checking.
|
||||
*/
|
||||
getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
||||
/**
|
||||
* Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
|
||||
* explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
|
||||
* `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
|
||||
* input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
|
||||
* `undefined`, as the result would have no impact on module resolution, emit, or type checking.
|
||||
*/
|
||||
getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
|
||||
getProjectReferences(): readonly ProjectReference[] | undefined;
|
||||
getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined;
|
||||
}
|
||||
@@ -7641,6 +7665,7 @@ declare namespace ts {
|
||||
ESNext = 99,
|
||||
Node16 = 100,
|
||||
NodeNext = 199,
|
||||
Preserve = 200,
|
||||
}
|
||||
enum JsxEmit {
|
||||
None = 0,
|
||||
@@ -9902,25 +9927,38 @@ declare namespace ts {
|
||||
*/
|
||||
function getModeForFileReference(ref: FileReference | string, containingFileMode: ResolutionMode): ResolutionMode;
|
||||
/**
|
||||
* Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
|
||||
* defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm).
|
||||
* If you have an actual import node, prefer using getModeForUsageLocation on the reference string node.
|
||||
* Use `program.getModeForResolutionAtIndex`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
|
||||
* Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
|
||||
* explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
|
||||
* `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
|
||||
* input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
|
||||
* `undefined`, as the result would have no impact on module resolution, emit, or type checking.
|
||||
* @param file File to fetch the resolution mode within
|
||||
* @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations
|
||||
* @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
|
||||
* should be the options of the referenced project, not the referencing project.
|
||||
*/
|
||||
function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
|
||||
function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
|
||||
/**
|
||||
* Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
|
||||
* one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
|
||||
* Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
|
||||
* `moduleResolution` is `node16`+.
|
||||
* Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
|
||||
* Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
|
||||
* attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
|
||||
* depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
|
||||
* `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
|
||||
* impact on module resolution, emit, or type checking.
|
||||
* @param file The file the import or import-like reference is contained within
|
||||
* @param usage The module reference string
|
||||
* @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
|
||||
* should be the options of the referenced project, not the referencing project.
|
||||
* @returns The final resolution mode of the import
|
||||
*/
|
||||
function getModeForUsageLocation(file: {
|
||||
impliedNodeFormat?: ResolutionMode;
|
||||
}, usage: StringLiteralLike): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
function getModeForUsageLocation(
|
||||
file: {
|
||||
impliedNodeFormat?: ResolutionMode;
|
||||
},
|
||||
usage: StringLiteralLike,
|
||||
compilerOptions: CompilerOptions,
|
||||
): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
|
||||
/**
|
||||
* A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
|
||||
|
||||
@@ -12,8 +12,8 @@ awaitInNonAsyncFunction.ts(30,9): error TS1103: 'for await' loops are only allow
|
||||
awaitInNonAsyncFunction.ts(31,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules.
|
||||
awaitInNonAsyncFunction.ts(34,7): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules.
|
||||
awaitInNonAsyncFunction.ts(35,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules.
|
||||
awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
|
||||
==== awaitInNonAsyncFunction.ts (16 errors) ====
|
||||
@@ -97,7 +97,7 @@ awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions ar
|
||||
|
||||
for await (const _ of []);
|
||||
~~~~~
|
||||
!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
await null;
|
||||
~~~~~
|
||||
!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
@@ -1,24 +1,24 @@
|
||||
awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
|
||||
==== awaitUsingDeclarations.1.ts (15 errors) ====
|
||||
await using d1 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
async function af() {
|
||||
await using d3 = { async [Symbol.asyncDispose]() {} };
|
||||
@@ -55,20 +55,20 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme
|
||||
{
|
||||
await using d19 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
switch (Math.random()) {
|
||||
case 0:
|
||||
await using d20 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
|
||||
case 1:
|
||||
await using d21 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -77,48 +77,48 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme
|
||||
case 0:
|
||||
await using d22 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
await using d23 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
catch {
|
||||
await using d24 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
finally {
|
||||
await using d25 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
if (true) {
|
||||
await using d26 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
else {
|
||||
await using d27 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
while (true) {
|
||||
await using d28 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
|
||||
do {
|
||||
await using d29 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
while (true);
|
||||
@@ -126,20 +126,20 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme
|
||||
for (;;) {
|
||||
await using d30 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
|
||||
for (const x in {}) {
|
||||
await using d31 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
for (const x of []) {
|
||||
await using d32 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -1,24 +1,24 @@
|
||||
awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
|
||||
==== awaitUsingDeclarations.1.ts (15 errors) ====
|
||||
await using d1 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
async function af() {
|
||||
await using d3 = { async [Symbol.asyncDispose]() {} };
|
||||
@@ -55,20 +55,20 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme
|
||||
{
|
||||
await using d19 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
switch (Math.random()) {
|
||||
case 0:
|
||||
await using d20 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
|
||||
case 1:
|
||||
await using d21 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -77,48 +77,48 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme
|
||||
case 0:
|
||||
await using d22 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
await using d23 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
catch {
|
||||
await using d24 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
finally {
|
||||
await using d25 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
if (true) {
|
||||
await using d26 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
else {
|
||||
await using d27 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
while (true) {
|
||||
await using d28 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
|
||||
do {
|
||||
await using d29 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
while (true);
|
||||
@@ -126,20 +126,20 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme
|
||||
for (;;) {
|
||||
await using d30 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
break;
|
||||
}
|
||||
|
||||
for (const x in {}) {
|
||||
await using d31 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
for (const x of []) {
|
||||
await using d32 = { async [Symbol.asyncDispose]() {} };
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -1,11 +1,11 @@
|
||||
awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
|
||||
==== awaitUsingDeclarations.2.ts (1 errors) ====
|
||||
{
|
||||
await using d1 = { async [Symbol.asyncDispose]() {} },
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
d2 = { async [Symbol.asyncDispose]() {} };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
|
||||
==== awaitUsingDeclarations.2.ts (1 errors) ====
|
||||
{
|
||||
await using d1 = { async [Symbol.asyncDispose]() {} },
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
d2 = { async [Symbol.asyncDispose]() {} };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
|
||||
==== awaitUsingDeclarations.3.ts (1 errors) ====
|
||||
{
|
||||
await using d1 = { async [Symbol.asyncDispose]() {} },
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
d2 = null,
|
||||
d3 = undefined,
|
||||
d4 = { [Symbol.dispose]() {} };
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
|
||||
|
||||
==== awaitUsingDeclarations.3.ts (1 errors) ====
|
||||
{
|
||||
await using d1 = { async [Symbol.asyncDispose]() {} },
|
||||
~~~~~
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
|
||||
!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.
|
||||
d2 = null,
|
||||
d3 = undefined,
|
||||
d4 = { [Symbol.dispose]() {} };
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,44 @@
|
||||
error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
|
||||
The file is in the program because:
|
||||
Root file specified for compilation
|
||||
error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
|
||||
The file is in the program because:
|
||||
Root file specified for compilation
|
||||
|
||||
|
||||
!!! error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
|
||||
!!! error TS6504: The file is in the program because:
|
||||
!!! error TS6504: Root file specified for compilation
|
||||
!!! error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
|
||||
!!! error TS6504: The file is in the program because:
|
||||
!!! error TS6504: Root file specified for compilation
|
||||
==== /node_modules/conditions/package.json (0 errors) ====
|
||||
{
|
||||
"name": "conditions",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"types": "index.d.cts",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": "./index.node.js",
|
||||
"default": "./index.web.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
==== /node_modules/conditions/index.node.js (0 errors) ====
|
||||
export const node = 0;
|
||||
|
||||
==== /node_modules/conditions/index.node.d.ts (0 errors) ====
|
||||
export const node: number;
|
||||
|
||||
==== /node_modules/conditions/index.web.js (0 errors) ====
|
||||
export const web = 0;
|
||||
|
||||
==== /node_modules/conditions/index.web.d.ts (0 errors) ====
|
||||
export const web: number;
|
||||
|
||||
==== /main.ts (0 errors) ====
|
||||
import { web } from "conditions";
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "conditions",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"types": "index.d.cts",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": "./index.node.js",
|
||||
"default": "./index.web.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [index.node.js]
|
||||
export const node = 0;
|
||||
|
||||
//// [index.node.d.ts]
|
||||
export const node: number;
|
||||
|
||||
//// [index.web.js]
|
||||
export const web = 0;
|
||||
|
||||
//// [index.web.d.ts]
|
||||
export const web: number;
|
||||
|
||||
//// [main.ts]
|
||||
import { web } from "conditions";
|
||||
|
||||
|
||||
//// [main.js]
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] ////
|
||||
|
||||
=== /node_modules/conditions/index.node.d.ts ===
|
||||
export const node: number;
|
||||
>node : Symbol(node, Decl(index.node.d.ts, 0, 12))
|
||||
|
||||
=== /node_modules/conditions/index.web.d.ts ===
|
||||
export const web: number;
|
||||
>web : Symbol(web, Decl(index.web.d.ts, 0, 12))
|
||||
|
||||
=== /main.ts ===
|
||||
import { web } from "conditions";
|
||||
>web : Symbol(web, Decl(main.ts, 0, 8))
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
[
|
||||
"======== Resolving module 'conditions' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"File '/package.json' does not exist.",
|
||||
"Loading module 'conditions' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Found 'package.json' at '/node_modules/conditions/package.json'.",
|
||||
"Entering conditional exports.",
|
||||
"Saw non-matching condition 'node'.",
|
||||
"Matched 'exports' condition 'default'.",
|
||||
"Using 'exports' subpath '.' with target './index.web.js'.",
|
||||
"File name '/node_modules/conditions/index.web.js' has a '.js' extension - stripping it.",
|
||||
"File '/node_modules/conditions/index.web.ts' does not exist.",
|
||||
"File '/node_modules/conditions/index.web.tsx' does not exist.",
|
||||
"File '/node_modules/conditions/index.web.d.ts' exists - use it as a name resolution result.",
|
||||
"Resolved under condition 'default'.",
|
||||
"Exiting conditional exports.",
|
||||
"Resolving real path for '/node_modules/conditions/index.web.d.ts', result '/node_modules/conditions/index.web.d.ts'.",
|
||||
"======== Module name 'conditions' was successfully resolved to '/node_modules/conditions/index.web.d.ts' with Package ID 'conditions/index.web.d.ts@1.0.0'. ========",
|
||||
"======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-es5'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-es5'",
|
||||
"Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-es5' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators'",
|
||||
"Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-decorators' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators/legacy'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators/legacy'",
|
||||
"Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-dom'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-dom'",
|
||||
"Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-dom' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-webworker/importscripts'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-webworker/importscripts'",
|
||||
"Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-scripthost'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-scripthost'",
|
||||
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-scripthost' was not resolved. ========"
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] ////
|
||||
|
||||
=== /node_modules/conditions/index.node.d.ts ===
|
||||
export const node: number;
|
||||
>node : number
|
||||
|
||||
=== /node_modules/conditions/index.web.d.ts ===
|
||||
export const web: number;
|
||||
>web : number
|
||||
|
||||
=== /main.ts ===
|
||||
import { web } from "conditions";
|
||||
>web : number
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] ////
|
||||
|
||||
//// [esm.mts]
|
||||
export const esm = 0;
|
||||
|
||||
//// [not-actually-cjs.cts]
|
||||
import { esm } from "./esm.mjs";
|
||||
|
||||
//// [package.json]
|
||||
{ "type": "commonjs" }
|
||||
|
||||
//// [still-not-cjs.ts]
|
||||
import { esm } from "./esm.mjs";
|
||||
|
||||
|
||||
//// [esm.mjs]
|
||||
export var esm = 0;
|
||||
//// [not-actually-cjs.cjs]
|
||||
//// [still-not-cjs.js]
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] ////
|
||||
|
||||
=== /esm.mts ===
|
||||
export const esm = 0;
|
||||
>esm : Symbol(esm, Decl(esm.mts, 0, 12))
|
||||
|
||||
=== /not-actually-cjs.cts ===
|
||||
import { esm } from "./esm.mjs";
|
||||
>esm : Symbol(esm, Decl(not-actually-cjs.cts, 0, 8))
|
||||
|
||||
=== /still-not-cjs.ts ===
|
||||
import { esm } from "./esm.mjs";
|
||||
>esm : Symbol(esm, Decl(still-not-cjs.ts, 0, 8))
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] ////
|
||||
|
||||
=== /esm.mts ===
|
||||
export const esm = 0;
|
||||
>esm : 0
|
||||
>0 : 0
|
||||
|
||||
=== /not-actually-cjs.cts ===
|
||||
import { esm } from "./esm.mjs";
|
||||
>esm : 0
|
||||
|
||||
=== /still-not-cjs.ts ===
|
||||
import { esm } from "./esm.mjs";
|
||||
>esm : 0
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,59 @@
|
||||
error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option?
|
||||
The file is in the program because:
|
||||
Root file specified for compilation
|
||||
error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
|
||||
The file is in the program because:
|
||||
Root file specified for compilation
|
||||
/main.cts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'.
|
||||
/main.mts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'.
|
||||
/main.ts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'.
|
||||
|
||||
|
||||
!!! error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option?
|
||||
!!! error TS6504: The file is in the program because:
|
||||
!!! error TS6504: Root file specified for compilation
|
||||
!!! error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
|
||||
!!! error TS6504: The file is in the program because:
|
||||
!!! error TS6504: Root file specified for compilation
|
||||
==== /node_modules/dual/package.json (0 errors) ====
|
||||
{
|
||||
"name": "dual",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"types": "index.d.cts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./index.js",
|
||||
"require": "./index.cjs"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
==== /node_modules/dual/index.js (0 errors) ====
|
||||
export const esm = 0;
|
||||
|
||||
==== /node_modules/dual/index.d.ts (0 errors) ====
|
||||
export const esm: number;
|
||||
|
||||
==== /node_modules/dual/index.cjs (0 errors) ====
|
||||
exports.cjs = 0;
|
||||
|
||||
==== /node_modules/dual/index.d.cts (0 errors) ====
|
||||
export const cjs: number;
|
||||
|
||||
==== /main.ts (1 errors) ====
|
||||
import { esm, cjs } from "dual";
|
||||
~~~
|
||||
!!! error TS2305: Module '"dual"' has no exported member 'cjs'.
|
||||
|
||||
==== /main.mts (1 errors) ====
|
||||
import { esm, cjs } from "dual";
|
||||
~~~
|
||||
!!! error TS2305: Module '"dual"' has no exported member 'cjs'.
|
||||
|
||||
==== /main.cts (1 errors) ====
|
||||
import { esm, cjs } from "dual";
|
||||
~~~
|
||||
!!! error TS2305: Module '"dual"' has no exported member 'cjs'.
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "dual",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "index.cjs",
|
||||
"types": "index.d.cts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./index.js",
|
||||
"require": "./index.cjs"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [index.js]
|
||||
export const esm = 0;
|
||||
|
||||
//// [index.d.ts]
|
||||
export const esm: number;
|
||||
|
||||
//// [index.cjs]
|
||||
exports.cjs = 0;
|
||||
|
||||
//// [index.d.cts]
|
||||
export const cjs: number;
|
||||
|
||||
//// [main.ts]
|
||||
import { esm, cjs } from "dual";
|
||||
|
||||
//// [main.mts]
|
||||
import { esm, cjs } from "dual";
|
||||
|
||||
//// [main.cts]
|
||||
import { esm, cjs } from "dual";
|
||||
|
||||
|
||||
//// [main.js]
|
||||
//// [main.mjs]
|
||||
//// [main.cjs]
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] ////
|
||||
|
||||
=== /node_modules/dual/index.d.ts ===
|
||||
export const esm: number;
|
||||
>esm : Symbol(esm, Decl(index.d.ts, 0, 12))
|
||||
|
||||
=== /node_modules/dual/index.d.cts ===
|
||||
export const cjs: number;
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 0, 12))
|
||||
|
||||
=== /main.ts ===
|
||||
import { esm, cjs } from "dual";
|
||||
>esm : Symbol(esm, Decl(main.ts, 0, 8))
|
||||
>cjs : Symbol(cjs, Decl(main.ts, 0, 13))
|
||||
|
||||
=== /main.mts ===
|
||||
import { esm, cjs } from "dual";
|
||||
>esm : Symbol(esm, Decl(main.mts, 0, 8))
|
||||
>cjs : Symbol(cjs, Decl(main.mts, 0, 13))
|
||||
|
||||
=== /main.cts ===
|
||||
import { esm, cjs } from "dual";
|
||||
>esm : Symbol(esm, Decl(main.cts, 0, 8))
|
||||
>cjs : Symbol(cjs, Decl(main.cts, 0, 13))
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
[
|
||||
"======== Resolving module 'dual' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"File '/package.json' does not exist.",
|
||||
"Loading module 'dual' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Found 'package.json' at '/node_modules/dual/package.json'.",
|
||||
"Entering conditional exports.",
|
||||
"Matched 'exports' condition 'import'.",
|
||||
"Using 'exports' subpath '.' with target './index.js'.",
|
||||
"File name '/node_modules/dual/index.js' has a '.js' extension - stripping it.",
|
||||
"File '/node_modules/dual/index.ts' does not exist.",
|
||||
"File '/node_modules/dual/index.tsx' does not exist.",
|
||||
"File '/node_modules/dual/index.d.ts' exists - use it as a name resolution result.",
|
||||
"Resolved under condition 'import'.",
|
||||
"Exiting conditional exports.",
|
||||
"Resolving real path for '/node_modules/dual/index.d.ts', result '/node_modules/dual/index.d.ts'.",
|
||||
"======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========",
|
||||
"======== Resolving module 'dual' from '/main.mts'. ========",
|
||||
"Resolution for module 'dual' was found in cache from location '/'.",
|
||||
"======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========",
|
||||
"======== Resolving module 'dual' from '/main.cts'. ========",
|
||||
"Resolution for module 'dual' was found in cache from location '/'.",
|
||||
"======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========",
|
||||
"======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-es5'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-es5'",
|
||||
"Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-es5' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators'",
|
||||
"Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-decorators' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators/legacy'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators/legacy'",
|
||||
"Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-dom'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-dom'",
|
||||
"Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-dom' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-webworker/importscripts'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-webworker/importscripts'",
|
||||
"Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-scripthost'",
|
||||
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-scripthost'",
|
||||
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-scripthost' was not resolved. ========"
|
||||
]
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] ////
|
||||
|
||||
=== /node_modules/dual/index.d.ts ===
|
||||
export const esm: number;
|
||||
>esm : number
|
||||
|
||||
=== /node_modules/dual/index.d.cts ===
|
||||
export const cjs: number;
|
||||
>cjs : number
|
||||
|
||||
=== /main.ts ===
|
||||
import { esm, cjs } from "dual";
|
||||
>esm : number
|
||||
>cjs : any
|
||||
|
||||
=== /main.mts ===
|
||||
import { esm, cjs } from "dual";
|
||||
>esm : number
|
||||
>cjs : any
|
||||
|
||||
=== /main.cts ===
|
||||
import { esm, cjs } from "dual";
|
||||
>esm : number
|
||||
>cjs : any
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/tsconfig.json(4,25): error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
/tsconfig.json(4,25): error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
|
||||
|
||||
==== /tsconfig.json (1 errors) ====
|
||||
@@ -7,7 +7,7 @@
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "bundler",
|
||||
~~~~~~~~~
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
"noEmit": true
|
||||
}
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,39 @@
|
||||
/main.ts(4,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
|
||||
/main.ts(7,16): error TS2307: Cannot find module './redirect/index' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== /dir/index.ts (0 errors) ====
|
||||
export const x = 0;
|
||||
|
||||
==== /redirect/package.json (0 errors) ====
|
||||
{ "main": "../foo" }
|
||||
|
||||
==== /foo/index.ts (0 errors) ====
|
||||
export const y = 0;
|
||||
|
||||
==== /types/esm.d.ts (0 errors) ====
|
||||
declare const _: string;
|
||||
export default _;
|
||||
|
||||
==== /types/cjs.d.ts (0 errors) ====
|
||||
declare const _: string;
|
||||
export = _;
|
||||
|
||||
==== /main.ts (2 errors) ====
|
||||
import { x } from "./dir";
|
||||
import {} from "./dir/index";
|
||||
import {} from "./dir/index.js";
|
||||
import {} from "./dir/index.ts";
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
|
||||
|
||||
import { y } from "./redirect";
|
||||
import {} from "./redirect/index";
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module './redirect/index' or its corresponding type declarations.
|
||||
|
||||
import a from "./types/esm";
|
||||
import * as esm from "./types/esm";
|
||||
import b from "./types/cjs";
|
||||
import * as cjs from "./types/cjs";
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] ////
|
||||
|
||||
//// [index.ts]
|
||||
export const x = 0;
|
||||
|
||||
//// [package.json]
|
||||
{ "main": "../foo" }
|
||||
|
||||
//// [index.ts]
|
||||
export const y = 0;
|
||||
|
||||
//// [esm.d.ts]
|
||||
declare const _: string;
|
||||
export default _;
|
||||
|
||||
//// [cjs.d.ts]
|
||||
declare const _: string;
|
||||
export = _;
|
||||
|
||||
//// [main.ts]
|
||||
import { x } from "./dir";
|
||||
import {} from "./dir/index";
|
||||
import {} from "./dir/index.js";
|
||||
import {} from "./dir/index.ts";
|
||||
|
||||
import { y } from "./redirect";
|
||||
import {} from "./redirect/index";
|
||||
|
||||
import a from "./types/esm";
|
||||
import * as esm from "./types/esm";
|
||||
import b from "./types/cjs";
|
||||
import * as cjs from "./types/cjs";
|
||||
|
||||
|
||||
//// [index.js]
|
||||
export var x = 0;
|
||||
//// [index.js]
|
||||
export var y = 0;
|
||||
//// [main.js]
|
||||
@@ -0,0 +1,49 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] ////
|
||||
|
||||
=== /dir/index.ts ===
|
||||
export const x = 0;
|
||||
>x : Symbol(x, Decl(index.ts, 0, 12))
|
||||
|
||||
=== /foo/index.ts ===
|
||||
export const y = 0;
|
||||
>y : Symbol(y, Decl(index.ts, 0, 12))
|
||||
|
||||
=== /types/esm.d.ts ===
|
||||
declare const _: string;
|
||||
>_ : Symbol(_, Decl(esm.d.ts, 0, 13))
|
||||
|
||||
export default _;
|
||||
>_ : Symbol(_, Decl(esm.d.ts, 0, 13))
|
||||
|
||||
=== /types/cjs.d.ts ===
|
||||
declare const _: string;
|
||||
>_ : Symbol(_, Decl(cjs.d.ts, 0, 13))
|
||||
|
||||
export = _;
|
||||
>_ : Symbol(_, Decl(cjs.d.ts, 0, 13))
|
||||
|
||||
=== /main.ts ===
|
||||
import { x } from "./dir";
|
||||
>x : Symbol(x, Decl(main.ts, 0, 8))
|
||||
|
||||
import {} from "./dir/index";
|
||||
import {} from "./dir/index.js";
|
||||
import {} from "./dir/index.ts";
|
||||
|
||||
import { y } from "./redirect";
|
||||
>y : Symbol(y, Decl(main.ts, 5, 8))
|
||||
|
||||
import {} from "./redirect/index";
|
||||
|
||||
import a from "./types/esm";
|
||||
>a : Symbol(a, Decl(main.ts, 8, 6))
|
||||
|
||||
import * as esm from "./types/esm";
|
||||
>esm : Symbol(esm, Decl(main.ts, 9, 6))
|
||||
|
||||
import b from "./types/cjs";
|
||||
>b : Symbol(b, Decl(main.ts, 10, 6))
|
||||
|
||||
import * as cjs from "./types/cjs";
|
||||
>cjs : Symbol(cjs, Decl(main.ts, 11, 6))
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
[
|
||||
"======== Resolving module './dir' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"Loading module as file / folder, candidate module location '/dir', target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"File '/dir.ts' does not exist.",
|
||||
"File '/dir.tsx' does not exist.",
|
||||
"File '/dir.d.ts' does not exist.",
|
||||
"File '/dir.js' does not exist.",
|
||||
"File '/dir.jsx' does not exist.",
|
||||
"File '/dir/package.json' does not exist.",
|
||||
"File '/dir/index.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name './dir' was successfully resolved to '/dir/index.ts'. ========",
|
||||
"======== Resolving module './dir/index' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"Loading module as file / folder, candidate module location '/dir/index', target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"File '/dir/index.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name './dir/index' was successfully resolved to '/dir/index.ts'. ========",
|
||||
"======== Resolving module './dir/index.js' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"Loading module as file / folder, candidate module location '/dir/index.js', target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"File name '/dir/index.js' has a '.js' extension - stripping it.",
|
||||
"File '/dir/index.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name './dir/index.js' was successfully resolved to '/dir/index.ts'. ========",
|
||||
"======== Resolving module './dir/index.ts' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"Loading module as file / folder, candidate module location '/dir/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"File name '/dir/index.ts' has a '.ts' extension - stripping it.",
|
||||
"File '/dir/index.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name './dir/index.ts' was successfully resolved to '/dir/index.ts'. ========",
|
||||
"======== Resolving module './redirect' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"Loading module as file / folder, candidate module location '/redirect', target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"File '/redirect.ts' does not exist.",
|
||||
"File '/redirect.tsx' does not exist.",
|
||||
"File '/redirect.d.ts' does not exist.",
|
||||
"File '/redirect.js' does not exist.",
|
||||
"File '/redirect.jsx' does not exist.",
|
||||
"Found 'package.json' at '/redirect/package.json'.",
|
||||
"'package.json' does not have a 'typesVersions' field.",
|
||||
"'package.json' does not have a 'typings' field.",
|
||||
"'package.json' does not have a 'types' field.",
|
||||
"'package.json' has 'main' field '../foo' that references '/foo'.",
|
||||
"File '/foo' does not exist.",
|
||||
"Loading module as file / folder, candidate module location '/foo', target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"File '/foo.ts' does not exist.",
|
||||
"File '/foo.tsx' does not exist.",
|
||||
"File '/foo.d.ts' does not exist.",
|
||||
"File '/foo.js' does not exist.",
|
||||
"File '/foo.jsx' does not exist.",
|
||||
"File '/foo/index.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name './redirect' was successfully resolved to '/foo/index.ts'. ========",
|
||||
"======== Resolving module './redirect/index' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"Loading module as file / folder, candidate module location '/redirect/index', target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"File '/redirect/index.ts' does not exist.",
|
||||
"File '/redirect/index.tsx' does not exist.",
|
||||
"File '/redirect/index.d.ts' does not exist.",
|
||||
"File '/redirect/index.js' does not exist.",
|
||||
"File '/redirect/index.jsx' does not exist.",
|
||||
"Directory '/redirect/index' does not exist, skipping all lookups in it.",
|
||||
"======== Module name './redirect/index' was not resolved. ========",
|
||||
"======== Resolving module './types/esm' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"Loading module as file / folder, candidate module location '/types/esm', target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"File '/types/esm.ts' does not exist.",
|
||||
"File '/types/esm.tsx' does not exist.",
|
||||
"File '/types/esm.d.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name './types/esm' was successfully resolved to '/types/esm.d.ts'. ========",
|
||||
"======== Resolving module './types/cjs' from '/main.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Bundler'.",
|
||||
"Resolving in CJS mode with conditions 'import', 'types'.",
|
||||
"Loading module as file / folder, candidate module location '/types/cjs', target file types: TypeScript, JavaScript, Declaration, JSON.",
|
||||
"File '/types/cjs.ts' does not exist.",
|
||||
"File '/types/cjs.tsx' does not exist.",
|
||||
"File '/types/cjs.d.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name './types/cjs' was successfully resolved to '/types/cjs.d.ts'. ========",
|
||||
"======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-es5'",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-es5'",
|
||||
"Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-es5' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators'",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators'",
|
||||
"Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-decorators' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators/legacy'",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-decorators/legacy'",
|
||||
"Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-dom'",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-dom'",
|
||||
"Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-dom' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-webworker/importscripts'",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-webworker/importscripts'",
|
||||
"Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========",
|
||||
"======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Node10'.",
|
||||
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-scripthost'",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Scoped package detected, looking in 'typescript__lib-scripthost'",
|
||||
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"======== Module name '@typescript/lib-scripthost' was not resolved. ========"
|
||||
]
|
||||
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] ////
|
||||
|
||||
=== /dir/index.ts ===
|
||||
export const x = 0;
|
||||
>x : 0
|
||||
>0 : 0
|
||||
|
||||
=== /foo/index.ts ===
|
||||
export const y = 0;
|
||||
>y : 0
|
||||
>0 : 0
|
||||
|
||||
=== /types/esm.d.ts ===
|
||||
declare const _: string;
|
||||
>_ : string
|
||||
|
||||
export default _;
|
||||
>_ : string
|
||||
|
||||
=== /types/cjs.d.ts ===
|
||||
declare const _: string;
|
||||
>_ : string
|
||||
|
||||
export = _;
|
||||
>_ : string
|
||||
|
||||
=== /main.ts ===
|
||||
import { x } from "./dir";
|
||||
>x : 0
|
||||
|
||||
import {} from "./dir/index";
|
||||
import {} from "./dir/index.js";
|
||||
import {} from "./dir/index.ts";
|
||||
|
||||
import { y } from "./redirect";
|
||||
>y : 0
|
||||
|
||||
import {} from "./redirect/index";
|
||||
|
||||
import a from "./types/esm";
|
||||
>a : string
|
||||
|
||||
import * as esm from "./types/esm";
|
||||
>esm : typeof esm
|
||||
|
||||
import b from "./types/cjs";
|
||||
>b : string
|
||||
|
||||
import * as cjs from "./types/cjs";
|
||||
>cjs : string
|
||||
|
||||
+2
-2
@@ -25,12 +25,12 @@ error TS2468: Cannot find global value 'Promise'.
|
||||
import("./a");
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
|
||||
const _ = require("./a"); // No resolution
|
||||
const _ = require("./a");
|
||||
_.a; // any
|
||||
|
||||
==== /main.ts (2 errors) ====
|
||||
import {} from "./a";
|
||||
import _ = require("./a"); // Error
|
||||
import _ = require("./a"); // Error in esnext
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
|
||||
export = {}; // Error
|
||||
+3
-3
@@ -18,12 +18,12 @@ declare module "path" {
|
||||
//// [mainJs.js]
|
||||
import {} from "./a";
|
||||
import("./a");
|
||||
const _ = require("./a"); // No resolution
|
||||
const _ = require("./a");
|
||||
_.a; // any
|
||||
|
||||
//// [main.ts]
|
||||
import {} from "./a";
|
||||
import _ = require("./a"); // Error
|
||||
import _ = require("./a"); // Error in esnext
|
||||
export = {}; // Error
|
||||
export {};
|
||||
|
||||
@@ -35,7 +35,7 @@ export const a = "a";
|
||||
export var a = "a";
|
||||
//// [mainJs.js]
|
||||
import("./a");
|
||||
var _ = require("./a"); // No resolution
|
||||
var _ = require("./a");
|
||||
_.a; // any
|
||||
export {};
|
||||
//// [main.js]
|
||||
+6
-3
@@ -33,18 +33,21 @@ declare module "path" {
|
||||
=== /mainJs.js ===
|
||||
import {} from "./a";
|
||||
import("./a");
|
||||
>"./a" : Symbol("/a", Decl(a.ts, 0, 0))
|
||||
>"./a" : Symbol(_, Decl(a.ts, 0, 0))
|
||||
|
||||
const _ = require("./a"); // No resolution
|
||||
const _ = require("./a");
|
||||
>_ : Symbol(_, Decl(mainJs.js, 2, 5))
|
||||
>require : Symbol(require, Decl(index.d.ts, 0, 11))
|
||||
>"./a" : Symbol(_, Decl(a.ts, 0, 0))
|
||||
|
||||
_.a; // any
|
||||
>_.a : Symbol(_.a, Decl(a.ts, 0, 12))
|
||||
>_ : Symbol(_, Decl(mainJs.js, 2, 5))
|
||||
>a : Symbol(_.a, Decl(a.ts, 0, 12))
|
||||
|
||||
=== /main.ts ===
|
||||
import {} from "./a";
|
||||
import _ = require("./a"); // Error
|
||||
import _ = require("./a"); // Error in esnext
|
||||
>_ : Symbol(_, Decl(main.ts, 0, 21))
|
||||
|
||||
export = {}; // Error
|
||||
+8
-8
@@ -33,23 +33,23 @@ declare module "path" {
|
||||
=== /mainJs.js ===
|
||||
import {} from "./a";
|
||||
import("./a");
|
||||
>import("./a") : Promise<typeof import("/a")>
|
||||
>import("./a") : Promise<typeof _>
|
||||
>"./a" : "./a"
|
||||
|
||||
const _ = require("./a"); // No resolution
|
||||
>_ : any
|
||||
>require("./a") : any
|
||||
const _ = require("./a");
|
||||
>_ : typeof _
|
||||
>require("./a") : typeof _
|
||||
>require : (...args: any[]) => any
|
||||
>"./a" : "./a"
|
||||
|
||||
_.a; // any
|
||||
>_.a : any
|
||||
>_ : any
|
||||
>a : any
|
||||
>_.a : "a"
|
||||
>_ : typeof _
|
||||
>a : "a"
|
||||
|
||||
=== /main.ts ===
|
||||
import {} from "./a";
|
||||
import _ = require("./a"); // Error
|
||||
import _ = require("./a"); // Error in esnext
|
||||
>_ : typeof _
|
||||
|
||||
export = {}; // Error
|
||||
@@ -0,0 +1,37 @@
|
||||
error TS2468: Cannot find global value 'Promise'.
|
||||
/mainJs.js(2,1): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
|
||||
|
||||
|
||||
!!! error TS2468: Cannot find global value 'Promise'.
|
||||
==== /node_modules/@types/node/index.d.ts (0 errors) ====
|
||||
declare var require: (...args: any[]) => any;
|
||||
|
||||
==== /ambient.d.ts (0 errors) ====
|
||||
declare module "fs" {
|
||||
export function readFileSync(path: string, encoding?: string): string;
|
||||
}
|
||||
declare module "path" {
|
||||
import fs = require("fs"); // ok
|
||||
namespace path {
|
||||
export const sep: string;
|
||||
}
|
||||
export = path; // ok
|
||||
}
|
||||
|
||||
==== /mainJs.js (1 errors) ====
|
||||
import {} from "./a";
|
||||
import("./a");
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
|
||||
const _ = require("./a");
|
||||
_.a; // any
|
||||
|
||||
==== /main.ts (0 errors) ====
|
||||
import {} from "./a";
|
||||
import _ = require("./a"); // Error in esnext
|
||||
export = {}; // Error
|
||||
export {};
|
||||
|
||||
==== /a.ts (0 errors) ====
|
||||
export const a = "a";
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
declare var require: (...args: any[]) => any;
|
||||
|
||||
//// [ambient.d.ts]
|
||||
declare module "fs" {
|
||||
export function readFileSync(path: string, encoding?: string): string;
|
||||
}
|
||||
declare module "path" {
|
||||
import fs = require("fs"); // ok
|
||||
namespace path {
|
||||
export const sep: string;
|
||||
}
|
||||
export = path; // ok
|
||||
}
|
||||
|
||||
//// [mainJs.js]
|
||||
import {} from "./a";
|
||||
import("./a");
|
||||
const _ = require("./a");
|
||||
_.a; // any
|
||||
|
||||
//// [main.ts]
|
||||
import {} from "./a";
|
||||
import _ = require("./a"); // Error in esnext
|
||||
export = {}; // Error
|
||||
export {};
|
||||
|
||||
//// [a.ts]
|
||||
export const a = "a";
|
||||
|
||||
|
||||
//// [a.js]
|
||||
export var a = "a";
|
||||
//// [mainJs.js]
|
||||
import("./a");
|
||||
var _ = require("./a");
|
||||
_.a; // any
|
||||
//// [main.js]
|
||||
module.exports = {};
|
||||
@@ -0,0 +1,59 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] ////
|
||||
|
||||
=== /node_modules/@types/node/index.d.ts ===
|
||||
declare var require: (...args: any[]) => any;
|
||||
>require : Symbol(require, Decl(index.d.ts, 0, 11))
|
||||
>args : Symbol(args, Decl(index.d.ts, 0, 22))
|
||||
|
||||
=== /ambient.d.ts ===
|
||||
declare module "fs" {
|
||||
>"fs" : Symbol("fs", Decl(ambient.d.ts, 0, 0))
|
||||
|
||||
export function readFileSync(path: string, encoding?: string): string;
|
||||
>readFileSync : Symbol(readFileSync, Decl(ambient.d.ts, 0, 21))
|
||||
>path : Symbol(path, Decl(ambient.d.ts, 1, 33))
|
||||
>encoding : Symbol(encoding, Decl(ambient.d.ts, 1, 46))
|
||||
}
|
||||
declare module "path" {
|
||||
>"path" : Symbol("path", Decl(ambient.d.ts, 2, 1))
|
||||
|
||||
import fs = require("fs"); // ok
|
||||
>fs : Symbol(fs, Decl(ambient.d.ts, 3, 23))
|
||||
|
||||
namespace path {
|
||||
>path : Symbol(path, Decl(ambient.d.ts, 4, 30))
|
||||
|
||||
export const sep: string;
|
||||
>sep : Symbol(sep, Decl(ambient.d.ts, 6, 20))
|
||||
}
|
||||
export = path; // ok
|
||||
>path : Symbol(path, Decl(ambient.d.ts, 4, 30))
|
||||
}
|
||||
|
||||
=== /mainJs.js ===
|
||||
import {} from "./a";
|
||||
import("./a");
|
||||
>"./a" : Symbol(_, Decl(a.ts, 0, 0))
|
||||
|
||||
const _ = require("./a");
|
||||
>_ : Symbol(_, Decl(mainJs.js, 2, 5))
|
||||
>require : Symbol(require, Decl(index.d.ts, 0, 11))
|
||||
>"./a" : Symbol(_, Decl(a.ts, 0, 0))
|
||||
|
||||
_.a; // any
|
||||
>_.a : Symbol(_.a, Decl(a.ts, 0, 12))
|
||||
>_ : Symbol(_, Decl(mainJs.js, 2, 5))
|
||||
>a : Symbol(_.a, Decl(a.ts, 0, 12))
|
||||
|
||||
=== /main.ts ===
|
||||
import {} from "./a";
|
||||
import _ = require("./a"); // Error in esnext
|
||||
>_ : Symbol(_, Decl(main.ts, 0, 21))
|
||||
|
||||
export = {}; // Error
|
||||
export {};
|
||||
|
||||
=== /a.ts ===
|
||||
export const a = "a";
|
||||
>a : Symbol(a, Decl(a.ts, 0, 12))
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] ////
|
||||
|
||||
=== /node_modules/@types/node/index.d.ts ===
|
||||
declare var require: (...args: any[]) => any;
|
||||
>require : (...args: any[]) => any
|
||||
>args : any[]
|
||||
|
||||
=== /ambient.d.ts ===
|
||||
declare module "fs" {
|
||||
>"fs" : typeof import("fs")
|
||||
|
||||
export function readFileSync(path: string, encoding?: string): string;
|
||||
>readFileSync : (path: string, encoding?: string) => string
|
||||
>path : string
|
||||
>encoding : string
|
||||
}
|
||||
declare module "path" {
|
||||
>"path" : typeof import("path")
|
||||
|
||||
import fs = require("fs"); // ok
|
||||
>fs : typeof fs
|
||||
|
||||
namespace path {
|
||||
>path : typeof path
|
||||
|
||||
export const sep: string;
|
||||
>sep : string
|
||||
}
|
||||
export = path; // ok
|
||||
>path : typeof path
|
||||
}
|
||||
|
||||
=== /mainJs.js ===
|
||||
import {} from "./a";
|
||||
import("./a");
|
||||
>import("./a") : Promise<typeof _>
|
||||
>"./a" : "./a"
|
||||
|
||||
const _ = require("./a");
|
||||
>_ : typeof _
|
||||
>require("./a") : typeof _
|
||||
>require : (...args: any[]) => any
|
||||
>"./a" : "./a"
|
||||
|
||||
_.a; // any
|
||||
>_.a : "a"
|
||||
>_ : typeof _
|
||||
>a : "a"
|
||||
|
||||
=== /main.ts ===
|
||||
import {} from "./a";
|
||||
import _ = require("./a"); // Error in esnext
|
||||
>_ : typeof _
|
||||
|
||||
export = {}; // Error
|
||||
>{} : {}
|
||||
|
||||
export {};
|
||||
|
||||
=== /a.ts ===
|
||||
export const a = "a";
|
||||
>a : "a"
|
||||
>"a" : "a"
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
|
||||
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
==== /node_modules/dep/package.json (0 errors) ====
|
||||
// This documents bug https://github.com/microsoft/TypeScript/issues/50762.
|
||||
|
||||
|
||||
+1
-1
@@ -7,4 +7,4 @@ FileNames::
|
||||
0.ts
|
||||
Errors::
|
||||
error TS6044: Compiler option 'module' expects an argument.
|
||||
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.
|
||||
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'.
|
||||
+1
-1
@@ -25,5 +25,5 @@ CompilerOptions::
|
||||
"configFilePath": "tsconfig.json"
|
||||
}
|
||||
Errors::
|
||||
[91merror[0m[90m TS6046: [0mArgument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.
|
||||
[91merror[0m[90m TS6046: [0mArgument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'.
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ CompilerOptions::
|
||||
"configFilePath": "tsconfig.json"
|
||||
}
|
||||
Errors::
|
||||
[96mtsconfig.json[0m:[93m3[0m:[93m15[0m - [91merror[0m[90m TS6046: [0mArgument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.
|
||||
[96mtsconfig.json[0m:[93m3[0m:[93m15[0m - [91merror[0m[90m TS6046: [0mArgument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'.
|
||||
|
||||
[7m3[0m "module": "",
|
||||
[7m [0m [91m ~~[0m
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
|
||||
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
==== /node_modules/lodash/package.json (0 errors) ====
|
||||
{
|
||||
"name": "lodash",
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
|
||||
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
==== /node_modules/lodash/package.json (0 errors) ====
|
||||
{
|
||||
"name": "lodash",
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/compiler/emitHelpersWithLocalCollisions.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
declare var dec: any, __decorate: any;
|
||||
@dec export class A {
|
||||
}
|
||||
|
||||
const o = { a: 1 };
|
||||
const y = { ...o };
|
||||
|
||||
|
||||
//// [a.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
let A = class A {
|
||||
};
|
||||
A = __decorate([
|
||||
dec
|
||||
], A);
|
||||
export { A };
|
||||
const o = { a: 1 };
|
||||
const y = Object.assign({}, o);
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
|
||||
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later.
|
||||
!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.
|
||||
==== /project/a.js (0 errors) ====
|
||||
export default "a.js";
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.
|
||||
3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.
|
||||
3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.
|
||||
@@ -21,13 +21,13 @@
|
||||
==== 1.ts (3 errors) ====
|
||||
import './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import { a, b } from './0' assert { "type": "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import * as foo from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
a;
|
||||
b;
|
||||
foo.a;
|
||||
@@ -36,10 +36,10 @@
|
||||
==== 2.ts (2 errors) ====
|
||||
import { a, b } from './0' assert {}
|
||||
~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
a;
|
||||
b;
|
||||
c;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.
|
||||
3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.
|
||||
3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.
|
||||
@@ -21,13 +21,13 @@
|
||||
==== 1.ts (3 errors) ====
|
||||
import './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import { a, b } from './0' assert { "type": "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import * as foo from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
a;
|
||||
b;
|
||||
foo.a;
|
||||
@@ -36,10 +36,10 @@
|
||||
==== 2.ts (2 errors) ====
|
||||
import { a, b } from './0' assert {}
|
||||
~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
a;
|
||||
b;
|
||||
c;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
|
||||
|
||||
==== 0.ts (0 errors) ====
|
||||
@@ -13,22 +13,22 @@
|
||||
==== 1.ts (4 errors) ====
|
||||
export {} from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
export { a, b } from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
export * from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
export * as ns from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
|
||||
==== 2.ts (2 errors) ====
|
||||
export { a, b } from './0' assert {}
|
||||
~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
export { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
|
||||
|
||||
==== 0.ts (0 errors) ====
|
||||
@@ -13,22 +13,22 @@
|
||||
==== 1.ts (4 errors) ====
|
||||
export {} from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
export { a, b } from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
export * from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
export * as ns from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
|
||||
==== 2.ts (2 errors) ====
|
||||
export { a, b } from './0' assert {}
|
||||
~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
export { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
1.ts(1,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(2,30): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(1,31): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(2,33): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(1,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(2,30): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(1,31): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(2,33): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
|
||||
|
||||
==== 0.ts (0 errors) ====
|
||||
@@ -10,17 +10,17 @@
|
||||
==== 1.ts (2 errors) ====
|
||||
export type {} from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
export type { I } from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
|
||||
==== 2.ts (2 errors) ====
|
||||
import type { I } from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import type * as foo from './0' assert { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
1.ts(1,14): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(3,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(1,14): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(3,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.
|
||||
3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.
|
||||
3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.
|
||||
@@ -21,13 +21,13 @@
|
||||
==== 1.ts (3 errors) ====
|
||||
import './0' with { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import { a, b } from './0' with { "type": "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import * as foo from './0' with { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
a;
|
||||
b;
|
||||
foo.a;
|
||||
@@ -35,10 +35,10 @@
|
||||
==== 2.ts (2 errors) ====
|
||||
import { a, b } from './0' with {}
|
||||
~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import { a as c, b as d } from './0' with { a: "a", b: "b", c: "c" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
a;
|
||||
b;
|
||||
c;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
1.ts(1,14): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(3,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
1.ts(1,14): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
1.ts(3,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.
|
||||
3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.
|
||||
3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.
|
||||
@@ -21,13 +21,13 @@
|
||||
==== 1.ts (3 errors) ====
|
||||
import './0' with { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import { a, b } from './0' with { "type": "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import * as foo from './0' with { type: "json" }
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
a;
|
||||
b;
|
||||
foo.a;
|
||||
@@ -35,10 +35,10 @@
|
||||
==== 2.ts (2 errors) ====
|
||||
import { a, b } from './0' with {}
|
||||
~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
import { a as c, b as d } from './0' with { a: "a", b: "b", c: "c" }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
|
||||
!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.
|
||||
a;
|
||||
b;
|
||||
c;
|
||||
|
||||
Loaded 100 of 173 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user