From ad0ba4778be2f1cd4f279a9cc8440907188f658e Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Thu, 23 May 2024 17:04:23 -0400 Subject: [PATCH 01/11] Implement "Arbitrary Module Namespace Identifiers" --- src/compiler/binder.ts | 6 +- src/compiler/checker.ts | 123 +- src/compiler/diagnosticMessages.json | 4 + src/compiler/factory/nodeFactory.ts | 13 +- src/compiler/factory/nodeTests.ts | 5 + src/compiler/factory/utilities.ts | 4 + src/compiler/parser.ts | 55 +- src/compiler/transformers/module/module.ts | 86 +- src/compiler/transformers/module/system.ts | 43 +- src/compiler/transformers/utilities.ts | 40 +- src/compiler/types.ts | 24 +- src/compiler/utilities.ts | 24 +- src/compiler/visitorPublic.ts | 7 +- src/services/completions.ts | 3 +- src/services/findAllReferences.ts | 33 +- src/services/goToDefinition.ts | 8 +- src/services/importTracker.ts | 12 +- src/services/organizeImports.ts | 3 +- src/services/refactors/convertExport.ts | 5 +- src/services/refactors/convertImport.ts | 8 +- tests/baselines/reference/api/typescript.d.ts | 22 +- ...yModuleNamespaceIdentifiers_amd.errors.txt | 42 + ...arbitraryModuleNamespaceIdentifiers_amd.js | 69 + ...raryModuleNamespaceIdentifiers_amd.symbols | 82 + ...itraryModuleNamespaceIdentifiers_amd.types | 151 ++ ...leNamespaceIdentifiers_commonjs.errors.txt | 42 + ...raryModuleNamespaceIdentifiers_commonjs.js | 71 + ...oduleNamespaceIdentifiers_commonjs.symbols | 82 + ...yModuleNamespaceIdentifiers_commonjs.types | 151 ++ ...duleNamespaceIdentifiers_es2015.errors.txt | 84 + ...itraryModuleNamespaceIdentifiers_es2015.js | 68 + ...yModuleNamespaceIdentifiers_es2015.symbols | 82 + ...aryModuleNamespaceIdentifiers_es2015.types | 151 ++ ...duleNamespaceIdentifiers_es2022.errors.txt | 42 + ...itraryModuleNamespaceIdentifiers_es2022.js | 67 + ...yModuleNamespaceIdentifiers_es2022.symbols | 82 + ...aryModuleNamespaceIdentifiers_es2022.types | 151 ++ ...amespaceIdentifiers_exportEmpty.errors.txt | 13 + ...yModuleNamespaceIdentifiers_exportEmpty.js | 23 + ...leNamespaceIdentifiers_exportEmpty.symbols | 19 + ...duleNamespaceIdentifiers_exportEmpty.types | 27 + ...amespaceIdentifiers_importEmpty.errors.txt | 21 + ...yModuleNamespaceIdentifiers_importEmpty.js | 22 + ...leNamespaceIdentifiers_importEmpty.symbols | 22 + ...duleNamespaceIdentifiers_importEmpty.types | 31 + ...duleNamespaceIdentifiers_syntax.errors.txt | 70 + ...itraryModuleNamespaceIdentifiers_syntax.js | 78 + ...yModuleNamespaceIdentifiers_syntax.symbols | 98 + ...aryModuleNamespaceIdentifiers_syntax.types | 135 ++ ...duleNamespaceIdentifiers_system.errors.txt | 42 + ...itraryModuleNamespaceIdentifiers_system.js | 82 + ...yModuleNamespaceIdentifiers_system.symbols | 82 + ...aryModuleNamespaceIdentifiers_system.types | 151 ++ ...eNamespaceIdentifiers_types.baseline.jsonc | 1712 +++++++++++++++++ ...yModuleNamespaceIdentifiers_umd.errors.txt | 42 + ...arbitraryModuleNamespaceIdentifiers_umd.js | 81 + ...raryModuleNamespaceIdentifiers_umd.symbols | 82 + ...itraryModuleNamespaceIdentifiers_umd.types | 151 ++ ...NamespaceIdentifiers_values.baseline.jsonc | 1628 ++++++++++++++++ ...arbitraryModuleNamespaceIdentifiers_amd.ts | 33 + ...raryModuleNamespaceIdentifiers_commonjs.ts | 33 + ...itraryModuleNamespaceIdentifiers_es2015.ts | 33 + ...itraryModuleNamespaceIdentifiers_es2022.ts | 33 + ...yModuleNamespaceIdentifiers_exportEmpty.ts | 10 + ...yModuleNamespaceIdentifiers_importEmpty.ts | 12 + ...itraryModuleNamespaceIdentifiers_syntax.ts | 47 + ...itraryModuleNamespaceIdentifiers_system.ts | 33 + ...arbitraryModuleNamespaceIdentifiers_umd.ts | 33 + ...bitraryModuleNamespaceIdentifiers_types.ts | 19 + ...itraryModuleNamespaceIdentifiers_values.ts | 19 + ...ertImport_namedToNamespaceStringLiteral.ts | 17 + 71 files changed, 6712 insertions(+), 167 deletions(-) create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_types.baseline.jsonc create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_values.baseline.jsonc create mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts create mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts create mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts create mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts create mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_exportEmpty.ts create mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_importEmpty.ts create mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts create mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts create mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts create mode 100644 tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_types.ts create mode 100644 tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_values.ts create mode 100644 tests/cases/fourslash/refactorConvertImport_namedToNamespaceStringLiteral.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ea263f471cbdc..cab3c6911bf98 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -251,6 +251,7 @@ import { ModifierFlags, ModuleBlock, ModuleDeclaration, + moduleExportNameIsDefault, Mutable, NamespaceExportDeclaration, Node, @@ -433,6 +434,9 @@ function getModuleInstanceStateWorker(node: Node, visited: Map) { const name = specifier.propertyName || specifier.name; + if (name.kind !== SyntaxKind.Identifier) { + return ModuleInstanceState.Instantiated; // Skip for invalid syntax like this: export { "x" } + } let p: Node | undefined = specifier.parent; while (p) { if (isBlock(p) || isModuleBlock(p) || isSourceFile(p)) { @@ -759,7 +763,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { function declareSymbol(symbolTable: SymbolTable, parent: Symbol | undefined, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags, isReplaceableByMethod?: boolean, isComputedName?: boolean): Symbol { Debug.assert(isComputedName || !hasDynamicName(node)); - const isDefaultExport = hasSyntacticModifier(node, ModifierFlags.Default) || isExportSpecifier(node) && node.name.escapedText === "default"; + const isDefaultExport = hasSyntacticModifier(node, ModifierFlags.Default) || isExportSpecifier(node) && moduleExportNameIsDefault(node.name); // The exported symbol for an export default function/class node is always named "default" const name = isComputedName ? InternalSymbolName.Computed diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7266f90b86190..5414f798122b6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -860,12 +860,17 @@ import { modifierToFlag, ModuleBlock, ModuleDeclaration, + ModuleExportName, + moduleExportNameIsDefault, + moduleExportNameTextEscaped, + moduleExportNameTextUnescaped, ModuleInstanceState, ModuleKind, ModuleResolutionKind, ModuleSpecifierResolutionHost, Mutable, NamedDeclaration, + NamedExportBindings, NamedExports, NamedImportsOrExports, NamedTupleMember, @@ -3601,7 +3606,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { : Diagnostics._0_was_imported_here; // TODO: how to get name for export *? - const name = typeOnlyDeclaration.kind === SyntaxKind.ExportDeclaration ? "*" : unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText); + const name = typeOnlyDeclaration.kind === SyntaxKind.ExportDeclaration ? "*" : moduleExportNameTextUnescaped(typeOnlyDeclaration.name); addRelatedInfo(error(node.moduleReference, message), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name)); } } @@ -3836,12 +3841,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return result; } - function getExportOfModule(symbol: Symbol, name: Identifier, specifier: Declaration, dontResolveAlias: boolean): Symbol | undefined { + function getExportOfModule(symbol: Symbol, nameText: __String, specifier: Declaration, dontResolveAlias: boolean): Symbol | undefined { if (symbol.flags & SymbolFlags.Module) { - const exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); + const exportSymbol = getExportsOfSymbol(symbol).get(nameText); const resolved = resolveSymbol(exportSymbol, dontResolveAlias); - const exportStarDeclaration = getSymbolLinks(symbol).typeOnlyExportStarMap?.get(name.escapedText); - markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false, exportStarDeclaration, name.escapedText); + const exportStarDeclaration = getSymbolLinks(symbol).typeOnlyExportStarMap?.get(nameText); + markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false, exportStarDeclaration, nameText); return resolved; } } @@ -3859,13 +3864,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const moduleSpecifier = getExternalModuleRequireArgument(node) || (node as ImportDeclaration | ExportDeclaration | JSDocImportTag).moduleSpecifier!; const moduleSymbol = resolveExternalModuleName(node, moduleSpecifier)!; // TODO: GH#18217 const name = !isPropertyAccessExpression(specifier) && specifier.propertyName || specifier.name; - if (!isIdentifier(name)) { + if (!isIdentifier(name) && name.kind !== SyntaxKind.StringLiteral) { return undefined; } - const suppressInteropError = name.escapedText === InternalSymbolName.Default && allowSyntheticDefaultImports; + const nameText = moduleExportNameTextEscaped(name); + const suppressInteropError = nameText === InternalSymbolName.Default && allowSyntheticDefaultImports; const targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { - if (name.escapedText) { + // Note: The empty string is a valid module export name: + // + // import { "" as foo } from "./foo"; + // export { foo as "" }; + // + if (nameText || name.kind === SyntaxKind.StringLiteral) { if (isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } @@ -3873,16 +3884,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let symbolFromVariable: Symbol | undefined; // First check if module was specified with "export=". If so, get the member from the resolved type if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get(InternalSymbolName.ExportEquals)) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), nameText, /*skipObjectFunctionPropertyAugment*/ true); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText); + symbolFromVariable = getPropertyOfVariable(targetSymbol, nameText); } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); - let symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === InternalSymbolName.Default) { + let symbolFromModule = getExportOfModule(targetSymbol, nameText, specifier, dontResolveAlias); + if (symbolFromModule === undefined && nameText === InternalSymbolName.Default) { const file = moduleSymbol.declarations?.find(isSourceFile); if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -3900,10 +3911,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function errorNoModuleMemberSymbol(moduleSymbol: Symbol, targetSymbol: Symbol, node: Node, name: Identifier) { + function errorNoModuleMemberSymbol(moduleSymbol: Symbol, targetSymbol: Symbol, node: Node, name: ModuleExportName) { const moduleName = getFullyQualifiedName(moduleSymbol, node); const declarationName = declarationNameToString(name); - const suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol); + const suggestion = isIdentifier(name) ? getSuggestedSymbolForNonexistentModule(name, targetSymbol) : undefined; if (suggestion !== undefined) { const suggestionName = symbolToString(suggestion); const diagnostic = error(name, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName); @@ -3926,8 +3937,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function reportNonExportedMember(node: Node, name: Identifier, declarationName: string, moduleSymbol: Symbol, moduleName: string): void { - const localSymbol = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)?.locals?.get(name.escapedText); + function reportNonExportedMember(node: Node, name: ModuleExportName, declarationName: string, moduleSymbol: Symbol, moduleName: string): void { + const localSymbol = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)?.locals?.get(moduleExportNameTextEscaped(name)); const exports = moduleSymbol.exports; if (localSymbol) { const exportedEqualsSymbol = exports?.get(InternalSymbolName.ExportEquals); @@ -3949,7 +3960,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function reportInvalidImportEqualsExportMember(node: Node, name: Identifier, declarationName: string, moduleName: string) { + function reportInvalidImportEqualsExportMember(node: Node, name: ModuleExportName, declarationName: string, moduleName: string) { if (moduleKind >= ModuleKind.ES2015) { const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_a_default_import : Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; @@ -3970,7 +3981,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getTargetOfImportSpecifier(node: ImportSpecifier | BindingElement, dontResolveAlias: boolean): Symbol | undefined { - if (isImportSpecifier(node) && idText(node.propertyName || node.name) === InternalSymbolName.Default) { + if (isImportSpecifier(node) && moduleExportNameIsDefault(node.propertyName || node.name)) { const specifier = getModuleSpecifierForImportOrExport(node); const moduleSymbol = specifier && resolveExternalModuleName(node, specifier); if (moduleSymbol) { @@ -4003,7 +4014,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getTargetOfExportSpecifier(node: ExportSpecifier, meaning: SymbolFlags, dontResolveAlias?: boolean) { - if (idText(node.propertyName || node.name) === InternalSymbolName.Default) { + const name = node.propertyName || node.name; + if (moduleExportNameIsDefault(name)) { const specifier = getModuleSpecifierForImportOrExport(node); const moduleSymbol = specifier && resolveExternalModuleName(node, specifier); if (moduleSymbol) { @@ -4012,7 +4024,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } const resolved = node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : - resolveEntityName(node.propertyName || node.name, meaning, /*ignoreErrors*/ false, dontResolveAlias); + name.kind === SyntaxKind.StringLiteral ? undefined : // Skip for invalid syntax like this: export { "x" } + resolveEntityName(name, meaning, /*ignoreErrors*/ false, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false); return resolved; } @@ -8927,10 +8940,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (index >= 0) { const exportDecl = statements[index] as ExportDeclaration & { readonly exportClause: NamedExports; }; const replacements = mapDefined(exportDecl.exportClause.elements, e => { - if (!e.propertyName) { + if (!e.propertyName && e.name.kind !== SyntaxKind.StringLiteral) { // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + const name = e.name; const indices = indicesOf(statements); - const associatedIndices = filter(indices, i => nodeHasName(statements[i], e.name)); + const associatedIndices = filter(indices, i => nodeHasName(statements[i], name)); if (length(associatedIndices) && every(associatedIndices, i => canHaveExportModifier(statements[i]))) { for (const index of associatedIndices) { statements[index] = addExportModifier(statements[index] as Extract); @@ -9629,7 +9643,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function getSomeTargetNameFromDeclarations(declarations: Declaration[] | undefined) { return firstDefined(declarations, d => { if (isImportSpecifier(d) || isExportSpecifier(d)) { - return idText(d.propertyName || d.name); + return moduleExportNameTextUnescaped(d.propertyName || d.name); } if (isBinaryExpression(d) || isExportAssignment(d)) { const expression = isExportAssignment(d) ? d.expression : d.right; @@ -9833,8 +9847,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve const specifier = (node.parent.parent as ExportDeclaration).moduleSpecifier; - if (specifier && (node as ExportSpecifier).propertyName?.escapedText === InternalSymbolName.Default) { - verbatimTargetName = InternalSymbolName.Default; + if (specifier) { + const propertyName = (node as ExportSpecifier).propertyName; + if (propertyName && moduleExportNameIsDefault(propertyName)) { + verbatimTargetName = InternalSymbolName.Default; + } } // targetName is only used when the target is local, as otherwise the target is an alias that points at // another file @@ -10607,9 +10624,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined { + function collectLinkedAliases(node: ModuleExportName, setVisibility?: boolean): Node[] | undefined { let exportSymbol: Symbol | undefined; - if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) { + if (node.kind !== SyntaxKind.StringLiteral && node.parent && node.parent.kind === SyntaxKind.ExportAssignment) { exportSymbol = resolveName(node, node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*isUse*/ false); } else if (node.parent.kind === SyntaxKind.ExportSpecifier) { @@ -29219,8 +29236,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return; case SyntaxKind.ExportSpecifier: const exportDeclaration = (node as ExportSpecifier).parent.parent; - if (!(node as ExportSpecifier).isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) { - const symbol = resolveEntityName((node as ExportSpecifier).propertyName || (node as ExportSpecifier).name, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ true); + const name = (node as ExportSpecifier).propertyName || (node as ExportSpecifier).name; + if (!(node as ExportSpecifier).isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier && name.kind !== SyntaxKind.StringLiteral) { + const symbol = resolveEntityName(name, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ true); if (symbol && isParameterOrMutableLocalVariable(symbol)) { symbol.lastAssignmentPos = Number.MAX_VALUE; } @@ -29599,6 +29617,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function markExportSpecifierAliasReferenced(location: ExportSpecifier) { if (!location.parent.parent.moduleSpecifier && !location.isTypeOnly && !location.parent.parent.isTypeOnly) { const exportedName = location.propertyName || location.name; + if (exportedName.kind === SyntaxKind.StringLiteral) { + return; // Skip for invalid syntax like this: export { "x" } + } const symbol = resolveName(exportedName, exportedName.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { // Do nothing, non-local symbol @@ -29607,7 +29628,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const target = symbol && (symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol); if (!target || getSymbolFlags(target) & SymbolFlags.Value) { markExportAsReferenced(location); // marks export as used - markIdentifierAliasReferenced(location.propertyName || location.name); // marks target of export as used + markIdentifierAliasReferenced(exportedName); // marks target of export as used } } return; @@ -46546,6 +46567,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return true; } + function checkModuleExportName(name: ModuleExportName | undefined) { + if (name !== undefined && name.kind === SyntaxKind.StringLiteral && (moduleKind === ModuleKind.ES2015 || moduleKind === ModuleKind.ES2020)) { + grammarErrorOnNode(name, Diagnostics.Arbitrary_module_namespace_identifiers_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020); + } + } + function checkAliasSymbol(node: AliasDeclarationNode) { let symbol = getSymbolOfDeclaration(node); const target = resolveAlias(symbol); @@ -46568,7 +46595,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { Debug.assert(node.kind !== SyntaxKind.NamespaceExport); if (node.kind === SyntaxKind.ExportSpecifier) { const diag = error(errorNode, Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files); - const alreadyExportedSymbol = getSourceFileOfNode(node).symbol?.exports?.get((node.propertyName || node.name).escapedText); + const alreadyExportedSymbol = getSourceFileOfNode(node).symbol?.exports?.get(moduleExportNameTextEscaped(node.propertyName || node.name)); if (alreadyExportedSymbol === target) { const exportingDeclaration = alreadyExportedSymbol.declarations?.find(isJSDocNode); if (exportingDeclaration) { @@ -46641,7 +46668,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { : isType ? Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled : Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled; - const name = idText(node.kind === SyntaxKind.ImportSpecifier ? node.propertyName || node.name : node.name); + const name = moduleExportNameTextUnescaped(node.kind === SyntaxKind.ImportSpecifier ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo( error(node, message, name), isType ? undefined : typeOnlyAlias, @@ -46658,7 +46685,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. if (compilerOptions.verbatimModuleSyntax || getSourceFileOfNode(typeOnlyAlias) !== getSourceFileOfNode(node)) { - const name = idText(node.propertyName || node.name); + const name = moduleExportNameTextUnescaped(node.propertyName || node.name); const diagnostic = isType ? error(node, Diagnostics.Re_exporting_a_type_when_0_is_enabled_requires_using_export_type, isolatedModulesLikeFlagName) : error(node, Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_1_is_enabled, name, isolatedModulesLikeFlagName); @@ -46733,13 +46760,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function checkImportBinding(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportSpecifier) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if ( - node.kind === SyntaxKind.ImportSpecifier && - idText(node.propertyName || node.name) === "default" && - getESModuleInterop(compilerOptions) && - host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < ModuleKind.System - ) { - checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault); + if (node.kind === SyntaxKind.ImportSpecifier) { + checkModuleExportName(node.propertyName); + if ( + moduleExportNameIsDefault(node.propertyName || node.name) && + getESModuleInterop(compilerOptions) && + host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < ModuleKind.System + ) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault); + } } } @@ -46889,6 +46918,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } else if (node.exportClause) { checkAliasSymbol(node.exportClause); + checkModuleExportName(node.exportClause.name); } if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < ModuleKind.System) { if (node.exportClause) { @@ -46926,11 +46956,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function checkExportSpecifier(node: ExportSpecifier) { checkAliasSymbol(node); + checkModuleExportName(node.propertyName); + checkModuleExportName(node.name); if (getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); } if (!node.parent.parent.moduleSpecifier) { const exportedName = node.propertyName || node.name; + if (exportedName.kind === SyntaxKind.StringLiteral) { + return; // Skip for invalid syntax like this: export { "x" } + } // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) const symbol = resolveName(exportedName, exportedName.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { @@ -46944,7 +46979,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if ( getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < ModuleKind.System && - idText(node.propertyName || node.name) === "default" + moduleExportNameIsDefault(node.propertyName || node.name) ) { checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault); } @@ -48323,9 +48358,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { /** Returns the target of an export specifier without following aliases */ function getExportSpecifierLocalTargetSymbol(node: ExportSpecifier | Identifier): Symbol | undefined { if (isExportSpecifier(node)) { + const name = node.propertyName || node.name; return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); + name.kind === SyntaxKind.StringLiteral ? undefined : // Skip for invalid syntax like this: export { "x" } + resolveEntityName(name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } else { return resolveEntityName(node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); @@ -51578,7 +51615,7 @@ function isDeclarationNameOrImportPropertyName(name: Node): boolean { switch (name.parent.kind) { case SyntaxKind.ImportSpecifier: case SyntaxKind.ExportSpecifier: - return isIdentifier(name); + return isIdentifier(name) || name.kind === SyntaxKind.StringLiteral; default: return isDeclarationName(name); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 71b2c712b91cf..c63f2b36d1d32 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -8317,5 +8317,9 @@ "Enum member following a non-literal numeric member must have an initializer when 'isolatedModules' is enabled.": { "category": "Error", "code": 18056 + }, + "Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'.": { + "category": "Error", + "code": 18057 } } diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 9fcd2a4acf7c1..024eaa5c7f687 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -309,6 +309,7 @@ import { ModuleBlock, ModuleBody, ModuleDeclaration, + ModuleExportName, ModuleName, ModuleReference, Mutable, @@ -4842,7 +4843,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function createNamespaceExport(name: Identifier): NamespaceExport { + function createNamespaceExport(name: ModuleExportName): NamespaceExport { const node = createBaseDeclaration(SyntaxKind.NamespaceExport); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | @@ -4852,7 +4853,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function updateNamespaceExport(node: NamespaceExport, name: Identifier) { + function updateNamespaceExport(node: NamespaceExport, name: ModuleExportName) { return node.name !== name ? update(createNamespaceExport(name), node) : node; @@ -4875,7 +4876,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function createImportSpecifier(isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier) { + function createImportSpecifier(isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier) { const node = createBaseDeclaration(SyntaxKind.ImportSpecifier); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; @@ -4887,7 +4888,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier) { + function updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier) { return node.isTypeOnly !== isTypeOnly || node.propertyName !== propertyName || node.name !== name @@ -4994,7 +4995,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function createExportSpecifier(isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier) { + function createExportSpecifier(isTypeOnly: boolean, propertyName: string | ModuleExportName | undefined, name: string | ModuleExportName) { const node = createBaseNode(SyntaxKind.ExportSpecifier); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); @@ -5008,7 +5009,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier) { + function updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: ModuleExportName) { return node.isTypeOnly !== isTypeOnly || node.propertyName !== propertyName || node.name !== name diff --git a/src/compiler/factory/nodeTests.ts b/src/compiler/factory/nodeTests.ts index cd31b63f81843..8aa4bb02e83d2 100644 --- a/src/compiler/factory/nodeTests.ts +++ b/src/compiler/factory/nodeTests.ts @@ -146,6 +146,7 @@ import { MissingDeclaration, ModuleBlock, ModuleDeclaration, + ModuleExportName, NamedExports, NamedImports, NamedTupleMember, @@ -898,6 +899,10 @@ export function isExportSpecifier(node: Node): node is ExportSpecifier { return node.kind === SyntaxKind.ExportSpecifier; } +export function isModuleExportName(node: Node): node is ModuleExportName { + return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral; +} + export function isMissingDeclaration(node: Node): node is MissingDeclaration { return node.kind === SyntaxKind.MissingDeclaration; } diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 502ffd17db5e0..e7031781b728d 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -131,6 +131,7 @@ import { MinusToken, Modifier, ModifiersArray, + moduleExportNameTextUnescaped, ModuleKind, ModuleName, MultiplicativeOperator, @@ -802,6 +803,9 @@ export function getLocalNameForExternalImport(factory: NodeFactory, node: Import const namespaceDeclaration = getNamespaceDeclarationNode(node); if (namespaceDeclaration && !isDefaultImport(node) && !isExportNamespaceAsDefaultDeclaration(node)) { const name = namespaceDeclaration.name; + if (name.kind === SyntaxKind.StringLiteral) { + return factory.getGeneratedNameForNode(node); + } return isGeneratedIdentifier(name) ? name : factory.createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, name) || idText(name)); } if (node.kind === SyntaxKind.ImportDeclaration && node.importClause) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a63735ad6bfa2..3c2956954a9b9 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -257,6 +257,7 @@ import { modifiersToFlags, ModuleBlock, ModuleDeclaration, + ModuleExportName, ModuleKind, Mutable, NamedExportBindings, @@ -2911,6 +2912,9 @@ namespace Parser { if (token() === SyntaxKind.FromKeyword && lookAhead(nextTokenIsStringLiteral)) { return false; } + if (token() === SyntaxKind.StringLiteral) { + return true; // For "arbitrary module namespace identifiers" + } return tokenIsIdentifierOrKeyword(token()); case ParsingContext.JsxAttributes: return tokenIsIdentifierOrKeyword(token()) || token() === SyntaxKind.OpenBraceToken; @@ -8509,6 +8513,10 @@ namespace Parser { return finishNode(factory.createNamespaceImport(name), pos); } + function parseModuleExportName(parseName: () => Identifier): ModuleExportName { + return token() === SyntaxKind.StringLiteral ? parseLiteralNode() as StringLiteral : parseName(); + } + function parseNamedImportsOrExports(kind: SyntaxKind.NamedImports): NamedImports; function parseNamedImportsOrExports(kind: SyntaxKind.NamedExports): NamedExports; function parseNamedImportsOrExports(kind: SyntaxKind): NamedImportsOrExports { @@ -8541,18 +8549,18 @@ namespace Parser { const pos = getNodePos(); // ImportSpecifier: // BindingIdentifier - // IdentifierName as BindingIdentifier + // ModuleExportName as BindingIdentifier // ExportSpecifier: - // IdentifierName - // IdentifierName as IdentifierName + // ModuleExportName + // ModuleExportName as ModuleExportName let checkIdentifierIsKeyword = isKeyword(token()) && !isIdentifier(); let checkIdentifierStart = scanner.getTokenStart(); let checkIdentifierEnd = scanner.getTokenEnd(); let isTypeOnly = false; - let propertyName: Identifier | undefined; + let propertyName: ModuleExportName | undefined; let canParseAsKeyword = true; - let name = parseIdentifierName(); - if (name.escapedText === "type") { + let name = parseModuleExportName(parseIdentifierName); + if (name.kind === SyntaxKind.Identifier && name.escapedText === "type") { // If the first token of an import specifier is 'type', there are a lot of possibilities, // especially if we see 'as' afterwards: // @@ -8592,6 +8600,11 @@ namespace Parser { name = firstAs; } } + else if (token() === SyntaxKind.StringLiteral) { + // { type "something" as ... } + isTypeOnly = true; + name = parseLiteralNode() as StringLiteral; + } else if (tokenIsIdentifierOrKeyword(token())) { // { type something ...? } isTypeOnly = true; @@ -8599,16 +8612,16 @@ namespace Parser { } } - if (canParseAsKeyword && token() === SyntaxKind.AsKeyword) { + if ((kind === SyntaxKind.ImportSpecifier && name.kind === SyntaxKind.StringLiteral) || (canParseAsKeyword && token() === SyntaxKind.AsKeyword)) { propertyName = name; parseExpected(SyntaxKind.AsKeyword); - name = parseNameWithKeywordCheck(); + name = parseModuleExportName(parseNameWithKeywordCheck); } if (kind === SyntaxKind.ImportSpecifier && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected); } const node = kind === SyntaxKind.ImportSpecifier - ? factory.createImportSpecifier(isTypeOnly, propertyName, name) + ? factory.createImportSpecifier(isTypeOnly, propertyName, name as Identifier) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -8621,7 +8634,7 @@ namespace Parser { } function parseNamespaceExport(pos: number): NamespaceExport { - return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos); + return finishNode(factory.createNamespaceExport(parseModuleExportName(parseIdentifierName)), pos); } function parseExportDeclaration(pos: number, hasJSDoc: boolean, modifiers: NodeArray | undefined): ExportDeclaration { @@ -8653,6 +8666,28 @@ namespace Parser { if (moduleSpecifier && (currentToken === SyntaxKind.WithKeyword || currentToken === SyntaxKind.AssertKeyword) && !scanner.hasPrecedingLineBreak()) { attributes = parseImportAttributes(currentToken); } + + // String literals are only allowed in the export specifiers if there's + // a module present: + // + // // Valid: + // export { "x" } from "foo"; + // export { "x" as y } from "foo"; + // export { x as "y" }; + // + // // Invalid: + // export { "x" }; + // export { "x" as y }; + // + if (exportClause && exportClause.kind === SyntaxKind.NamedExports && !moduleSpecifier) { + for (const element of exportClause.elements) { + const name = element.propertyName || element.name; + if (name.kind === SyntaxKind.StringLiteral) { + parseErrorAt(skipTrivia(sourceText, name.pos), name.end, Diagnostics.Identifier_expected); + } + } + } + parseSemicolon(); setAwaitContext(savedAwaitContext); const node = factory.createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, attributes); diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 9336c54a40fb6..1944f9e15a288 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -121,7 +121,11 @@ import { mapDefined, Modifier, ModifierFlags, + ModuleExportName, + moduleExportNameIsDefault, + moduleExportNameTextUnescaped, ModuleKind, + NamespaceImport, Node, NodeArray, NodeFlags, @@ -276,7 +280,10 @@ export function transformModule(context: TransformationContext): (x: SourceFile factory.createExpressionStatement( reduceLeft( currentModuleInfo.exportedNames.slice(i, i + chunkSize), - (prev, nextId) => factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(idText(nextId))), prev), + (prev, nextId) => + nextId.kind === SyntaxKind.StringLiteral + ? factory.createAssignment(factory.createElementAccessExpression(factory.createIdentifier("exports"), factory.createStringLiteral(nextId.text)), prev) + : factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(idText(nextId))), prev), factory.createVoidZero() as Expression, ), ), @@ -611,7 +618,13 @@ export function transformModule(context: TransformationContext): (x: SourceFile append(statements, createUnderscoreUnderscoreESModule()); } if (some(currentModuleInfo.exportedNames)) { - append(statements, factory.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(idText(nextId))), prev), factory.createVoidZero() as Expression))); + append( + statements, + factory.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => + nextId.kind === SyntaxKind.StringLiteral + ? factory.createAssignment(factory.createElementAccessExpression(factory.createIdentifier("exports"), factory.createStringLiteral(nextId.text)), prev) + : factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(idText(nextId))), prev), factory.createVoidZero() as Expression)), + ); } if (some(currentModuleInfo.exportedFunctions)) { for (const f of currentModuleInfo.exportedFunctions) { @@ -1389,7 +1402,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile */ function visitTopLevelImportDeclaration(node: ImportDeclaration): VisitResult { let statements: Statement[] | undefined; - const namespaceDeclaration = getNamespaceDeclarationNode(node); + const namespaceDeclaration = getNamespaceDeclarationNode(node) as NamespaceImport | undefined; if (moduleKind !== ModuleKind.AMD) { if (!node.importClause) { // import "mod"; @@ -1613,16 +1626,27 @@ export function transformModule(context: TransformationContext): (x: SourceFile for (const specifier of node.exportClause.elements) { const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & InternalEmitFlags.NeverApplyImportHelper) && - idText(specifier.propertyName || specifier.name) === "default"; - const exportedValue = factory.createPropertyAccessExpression( - exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, - specifier.propertyName || specifier.name, - ); + moduleExportNameIsDefault(specifier.propertyName || specifier.name); + const specifierName = specifier.propertyName || specifier.name; + const exportedValue = specifierName.kind === SyntaxKind.StringLiteral + ? factory.createElementAccessExpression( + exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, + specifierName, + ) + : factory.createPropertyAccessExpression( + exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, + specifierName, + ); statements.push( setOriginalNode( setTextRange( factory.createExpressionStatement( - createExportExpression(factory.getExportName(specifier), exportedValue, /*location*/ undefined, /*liveBinding*/ true), + createExportExpression( + specifier.name.kind === SyntaxKind.StringLiteral ? factory.cloneNode(specifier.name) : factory.getExportName(specifier), + exportedValue, + /*location*/ undefined, + /*liveBinding*/ true, + ), ), specifier, ), @@ -1648,6 +1672,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile moduleKind !== ModuleKind.AMD ? createRequireCall(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : + node.exportClause.name.kind === SyntaxKind.StringLiteral ? generatedName : factory.createIdentifier(idText(node.exportClause.name)), ), ), @@ -2074,11 +2099,14 @@ export function transformModule(context: TransformationContext): (x: SourceFile * @param location The location to use for source maps and comments for the export. * @param allowComments Whether to allow comments on the export. */ - function appendExportStatement(statements: Statement[] | undefined, seen: IdentifierNameMap, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean): Statement[] | undefined { - if (!seen.has(exportName)) { + function appendExportStatement(statements: Statement[] | undefined, seen: IdentifierNameMap, exportName: ModuleExportName, expression: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean): Statement[] | undefined { + if (exportName.kind !== SyntaxKind.StringLiteral) { + if (seen.has(exportName)) { + return statements; + } seen.set(exportName, true); - statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding)); } + statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding)); return statements; } @@ -2108,7 +2136,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile * @param location The location to use for source maps and comments for the export. * @param allowComments An optional value indicating whether to emit comments for the statement. */ - function createExportStatement(name: Identifier, value: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean) { + function createExportStatement(name: ModuleExportName, value: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean) { const statement = setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /*location*/ undefined, liveBinding)), location); startOnNewLine(statement); if (!allowComments) { @@ -2125,7 +2153,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile * @param value The exported value. * @param location The location to use for source maps and comments for the export. */ - function createExportExpression(name: Identifier, value: Expression, location?: TextRange, liveBinding?: boolean) { + function createExportExpression(name: ModuleExportName, value: Expression, location?: TextRange, liveBinding?: boolean) { return setTextRange( liveBinding ? factory.createCallExpression( factory.createPropertyAccessExpression( @@ -2153,10 +2181,15 @@ export function transformModule(context: TransformationContext): (x: SourceFile ]), ], ) : factory.createAssignment( - factory.createPropertyAccessExpression( - factory.createIdentifier("exports"), - factory.cloneNode(name), - ), + name.kind === SyntaxKind.StringLiteral + ? factory.createElementAccessExpression( + factory.createIdentifier("exports"), + factory.cloneNode(name), + ) + : factory.createPropertyAccessExpression( + factory.createIdentifier("exports"), + factory.cloneNode(name), + ), value, ), location, @@ -2343,10 +2376,15 @@ export function transformModule(context: TransformationContext): (x: SourceFile else if (isImportSpecifier(importDeclaration)) { const name = importDeclaration.propertyName || importDeclaration.name; return setTextRange( - factory.createPropertyAccessExpression( - factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), - factory.cloneNode(name), - ), + name.kind === SyntaxKind.StringLiteral + ? factory.createElementAccessExpression( + factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), + factory.cloneNode(name), + ) + : factory.createPropertyAccessExpression( + factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), + factory.cloneNode(name), + ), /*location*/ node, ); } @@ -2395,7 +2433,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile * * @param name The name. */ - function getExports(name: Identifier): Identifier[] | undefined { + function getExports(name: Identifier): ModuleExportName[] | undefined { if (!isGeneratedIdentifier(name)) { const importDeclaration = resolver.getReferencedImportDeclaration(name); if (importDeclaration) { @@ -2423,7 +2461,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile else if (isFileLevelReservedGeneratedIdentifier(name)) { const exportSpecifiers = currentModuleInfo?.exportSpecifiers.get(name); if (exportSpecifiers) { - const exportedNames: Identifier[] = []; + const exportedNames: ModuleExportName[] = []; for (const exportSpecifier of exportSpecifiers) { exportedNames.push(exportSpecifier.name); } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 5f79baf03fe54..9f18140f3f3ed 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -92,6 +92,9 @@ import { map, MetaProperty, ModifierFlags, + ModuleExportName, + moduleExportNameIsDefault, + moduleExportNameTextUnescaped, moveEmitHelpers, Node, NodeFlags, @@ -455,7 +458,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc const exportedNames: ObjectLiteralElementLike[] = []; if (moduleInfo.exportedNames) { for (const exportedLocalName of moduleInfo.exportedNames) { - if (exportedLocalName.escapedText === "default") { + if (moduleExportNameIsDefault(exportedLocalName)) { continue; } @@ -646,10 +649,10 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc for (const e of entry.exportClause.elements) { properties.push( factory.createPropertyAssignment( - factory.createStringLiteral(idText(e.name)), + factory.createStringLiteral(moduleExportNameTextUnescaped(e.name)), factory.createElementAccessExpression( parameterName, - factory.createStringLiteral(idText(e.propertyName || e.name)), + factory.createStringLiteral(moduleExportNameTextUnescaped(e.propertyName || e.name)), ), ), ); @@ -672,7 +675,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc exportFunction, /*typeArguments*/ undefined, [ - factory.createStringLiteral(idText(entry.exportClause.name)), + factory.createStringLiteral(moduleExportNameTextUnescaped(entry.exportClause.name)), parameterName, ], ), @@ -1165,7 +1168,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc const exportSpecifiers = moduleInfo.exportSpecifiers.get(name); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { - if (exportSpecifier.name.escapedText !== excludeName) { + if (moduleExportNameTextUnescaped(exportSpecifier.name) !== excludeName) { statements = appendExportStatement(statements, exportSpecifier.name, name); } } @@ -1853,13 +1856,19 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc ); } else if (isImportSpecifier(importDeclaration)) { + const importedName = importDeclaration.propertyName || importDeclaration.name; return setTextRange( factory.createPropertyAssignment( factory.cloneNode(name), - factory.createPropertyAccessExpression( - factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), - factory.cloneNode(importDeclaration.propertyName || importDeclaration.name), - ), + importedName.kind === SyntaxKind.StringLiteral + ? factory.createElementAccessExpression( + factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), + factory.cloneNode(importedName), + ) + : factory.createPropertyAccessExpression( + factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), + factory.cloneNode(importedName), + ), ), /*location*/ node, ); @@ -1921,11 +1930,17 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc ); } else if (isImportSpecifier(importDeclaration)) { + const importedName = importDeclaration.propertyName || importDeclaration.name; return setTextRange( - factory.createPropertyAccessExpression( - factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), - factory.cloneNode(importDeclaration.propertyName || importDeclaration.name), - ), + importedName.kind === SyntaxKind.StringLiteral + ? factory.createElementAccessExpression( + factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), + factory.cloneNode(importedName), + ) + : factory.createPropertyAccessExpression( + factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), + factory.cloneNode(importedName), + ), /*location*/ node, ); } @@ -1994,7 +2009,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc else if (isGeneratedIdentifier(name) && isFileLevelReservedGeneratedIdentifier(name)) { const exportSpecifiers = moduleInfo?.exportSpecifiers.get(name); if (exportSpecifiers) { - const exportedNames: Identifier[] = []; + const exportedNames: ModuleExportName[] = []; for (const exportSpecifier of exportSpecifiers) { exportedNames.push(exportSpecifier.name); } diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index 893460cf7a42f..f848d9e46f3cb 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -42,7 +42,6 @@ import { ImportEqualsDeclaration, ImportSpecifier, InitializedPropertyDeclaration, - InternalSymbolName, isAutoAccessorPropertyDeclaration, isBindingPattern, isClassStaticBlockDeclaration, @@ -68,6 +67,9 @@ import { map, MethodDeclaration, ModifierFlags, + ModuleExportName, + moduleExportNameIsDefault, + moduleExportNameTextUnescaped, NamedExportBindings, NamedImportBindings, NamespaceExport, @@ -104,7 +106,7 @@ export interface ExternalModuleInfo { externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers exportSpecifiers: IdentifierNameMap; // file-local export specifiers by name (no reexports) exportedBindings: Identifier[][]; // exported names of local declarations - exportedNames: Identifier[] | undefined; // all exported names in the module, both local and reexported, excluding the names of locally exported function declarations + exportedNames: ModuleExportName[] | undefined; // all exported names in the module, both local and reexported, excluding the names of locally exported function declarations exportedFunctions: FunctionDeclaration[] | undefined; // all of the top-level exported function declarations exportEquals: ExportAssignment | undefined; // an export= declaration if one was present hasExportStarsToExportValues: boolean; // whether this module contains export* @@ -117,9 +119,7 @@ function containsDefaultReference(node: NamedImportBindings | NamedExportBinding } function isNamedDefaultReference(e: ImportSpecifier | ExportSpecifier): boolean { - return e.propertyName !== undefined ? - e.propertyName.escapedText === InternalSymbolName.Default : - e.name.escapedText === InternalSymbolName.Default; + return moduleExportNameIsDefault(e.propertyName || e.name); } /** @internal */ @@ -174,7 +174,7 @@ export function collectExternalModuleInfo(context: TransformationContext, source const exportSpecifiers = new IdentifierNameMultiMap(); const exportedBindings: Identifier[][] = []; const uniqueExports = new Map(); - let exportedNames: Identifier[] | undefined; + let exportedNames: ModuleExportName[] | undefined; let exportedFunctions: FunctionDeclaration[] | undefined; let hasExportDefault = false; let exportEquals: ExportAssignment | undefined; @@ -223,9 +223,10 @@ export function collectExternalModuleInfo(context: TransformationContext, source } else { const name = ((node as ExportDeclaration).exportClause as NamespaceExport).name; - if (!uniqueExports.get(idText(name))) { + const nameText = moduleExportNameTextUnescaped(name); + if (!uniqueExports.get(nameText)) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); - uniqueExports.set(idText(name), true); + uniqueExports.set(nameText, true); exportedNames = append(exportedNames, name); } // we use the same helpers for `export * as ns` as we do for `import * as ns` @@ -307,27 +308,30 @@ export function collectExternalModuleInfo(context: TransformationContext, source function addExportedNamesForExportDeclaration(node: ExportDeclaration) { for (const specifier of cast(node.exportClause, isNamedExports).elements) { - if (!uniqueExports.get(idText(specifier.name))) { + const specifierNameText = moduleExportNameTextUnescaped(specifier.name); + if (!uniqueExports.get(specifierNameText)) { const name = specifier.propertyName || specifier.name; - if (!node.moduleSpecifier) { - exportSpecifiers.add(name, specifier); - } + if (name.kind !== SyntaxKind.StringLiteral) { + if (!node.moduleSpecifier) { + exportSpecifiers.add(name, specifier); + } - const decl = resolver.getReferencedImportDeclaration(name) - || resolver.getReferencedValueDeclaration(name); + const decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); - if (decl) { - multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + if (decl) { + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + } } - uniqueExports.set(idText(specifier.name), true); + uniqueExports.set(specifierNameText, true); exportedNames = append(exportedNames, specifier.name); } } } } -function collectExportedVariableInfo(decl: VariableDeclaration | BindingElement, uniqueExports: Map, exportedNames: Identifier[] | undefined, exportedBindings: Identifier[][]) { +function collectExportedVariableInfo(decl: VariableDeclaration | BindingElement, uniqueExports: Map, exportedNames: ModuleExportName[] | undefined, exportedBindings: Identifier[][]) { if (isBindingPattern(decl.name)) { for (const element of decl.name.elements) { if (!isOmittedExpression(element)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b3c58c5c72719..f3b70d59f96e8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3717,7 +3717,7 @@ export interface NamespaceImport extends NamedDeclaration { export interface NamespaceExport extends NamedDeclaration { readonly kind: SyntaxKind.NamespaceExport; readonly parent: ExportDeclaration; - readonly name: Identifier; + readonly name: ModuleExportName; } export interface NamespaceExportDeclaration extends DeclarationStatement, JSDocContainer { @@ -3758,7 +3758,7 @@ export type NamedImportsOrExports = NamedImports | NamedExports; export interface ImportSpecifier extends NamedDeclaration { readonly kind: SyntaxKind.ImportSpecifier; readonly parent: NamedImports; - readonly propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) + readonly propertyName?: ModuleExportName; // Name preceding "as" keyword (or undefined when "as" is absent) readonly name: Identifier; // Declared name readonly isTypeOnly: boolean; } @@ -3767,10 +3767,12 @@ export interface ExportSpecifier extends NamedDeclaration, JSDocContainer { readonly kind: SyntaxKind.ExportSpecifier; readonly parent: NamedExports; readonly isTypeOnly: boolean; - readonly propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) - readonly name: Identifier; // Declared name + readonly propertyName?: ModuleExportName; // Name preceding "as" keyword (or undefined when "as" is absent) + readonly name: ModuleExportName; // Declared name } +export type ModuleExportName = Identifier | StringLiteral; + export type ImportOrExportSpecifier = | ImportSpecifier | ExportSpecifier; @@ -5765,7 +5767,7 @@ export interface EmitResolver { getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean; isLateBound(node: Declaration): node is LateBoundDeclaration; - collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined; + collectLinkedAliases(node: ModuleExportName, setVisibility?: boolean): Node[] | undefined; isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined; requiresAddingImplicitUndefined(node: ParameterDeclaration): boolean; isExpandoFunctionDeclaration(node: FunctionDeclaration | VariableDeclaration): boolean; @@ -8877,20 +8879,20 @@ export interface NodeFactory { updateImportAttribute(node: ImportAttribute, name: ImportAttributeName, value: Expression): ImportAttribute; createNamespaceImport(name: Identifier): NamespaceImport; updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - createNamespaceExport(name: Identifier): NamespaceExport; - updateNamespaceExport(node: NamespaceExport, name: Identifier): NamespaceExport; + createNamespaceExport(name: ModuleExportName): NamespaceExport; + updateNamespaceExport(node: NamespaceExport, name: ModuleExportName): NamespaceExport; createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; - createImportSpecifier(isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + createImportSpecifier(isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier): ImportSpecifier; + updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier): ImportSpecifier; createExportAssignment(modifiers: readonly ModifierLike[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; updateExportAssignment(node: ExportAssignment, modifiers: readonly ModifierLike[] | undefined, expression: Expression): ExportAssignment; createExportDeclaration(modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, attributes?: ImportAttributes): ExportDeclaration; updateExportDeclaration(node: ExportDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, attributes: ImportAttributes | undefined): ExportDeclaration; createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; - createExportSpecifier(isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; - updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; + createExportSpecifier(isTypeOnly: boolean, propertyName: string | ModuleExportName | undefined, name: string | ModuleExportName): ExportSpecifier; + updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: ModuleExportName): ExportSpecifier; /** @internal */ createMissingDeclaration(): MissingDeclaration; // diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4cf5f0082cd20..2f8b27948ad2f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -420,6 +420,7 @@ import { ModuleBlock, ModuleDeclaration, ModuleDetectionKind, + ModuleExportName, ModuleKind, ModuleResolutionKind, moduleResolutionOptionDeclarations, @@ -1218,7 +1219,28 @@ function isJSDocTypeExpressionOrChild(node: Node): boolean { /** @internal */ export function isExportNamespaceAsDefaultDeclaration(node: Node): boolean { - return !!(isExportDeclaration(node) && node.exportClause && isNamespaceExport(node.exportClause) && node.exportClause.name.escapedText === "default"); + return !!(isExportDeclaration(node) && node.exportClause && isNamespaceExport(node.exportClause) && moduleExportNameIsDefault(node.exportClause.name)); +} + +/** @internal */ +export function moduleExportNameTextUnescaped(node: ModuleExportName): string { + return node.kind === SyntaxKind.StringLiteral ? node.text : unescapeLeadingUnderscores(node.escapedText); +} + +/** @internal */ +export function moduleExportNameTextEscaped(node: ModuleExportName): __String { + return node.kind === SyntaxKind.StringLiteral ? escapeLeadingUnderscores(node.text) : node.escapedText; +} + +/** + * Equality checks against a keyword without underscores don't need to bother + * to turn "__" into "___" or vice versa, since they will never be equal in + * either case. So we can ignore those cases to improve performance. + * + * @internal + */ +export function moduleExportNameIsDefault(node: ModuleExportName): boolean { + return (node.kind === SyntaxKind.StringLiteral ? node.text : node.escapedText) === InternalSymbolName.Default; } /** @internal */ diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 21e477329270e..f3e71e026d9be 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -59,6 +59,7 @@ import { isModifier, isModifierLike, isModuleBody, + isModuleExportName, isModuleName, isModuleReference, isNamedExportBindings, @@ -1579,7 +1580,7 @@ const visitEachChildTable: VisitEachChildTable = { return context.factory.updateImportSpecifier( node, node.isTypeOnly, - nodeVisitor(node.propertyName, visitor, isIdentifier), + nodeVisitor(node.propertyName, visitor, isModuleExportName), Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier)), ); }, @@ -1614,8 +1615,8 @@ const visitEachChildTable: VisitEachChildTable = { return context.factory.updateExportSpecifier( node, node.isTypeOnly, - nodeVisitor(node.propertyName, visitor, isIdentifier), - Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier)), + nodeVisitor(node.propertyName, visitor, isModuleExportName), + Debug.checkDefined(nodeVisitor(node.name, visitor, isModuleExportName)), ); }, diff --git a/src/services/completions.ts b/src/services/completions.ts index d09e81736433f..7dcb68f22165b 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -297,6 +297,7 @@ import { ModifierSyntaxKind, modifierToFlag, ModuleDeclaration, + moduleExportNameTextEscaped, ModuleReference, moduleResolutionSupportsPackageJsonExportsAndImports, NamedImportBindings, @@ -4497,7 +4498,7 @@ function getCompletionData( completionKind = CompletionKind.MemberLike; isNewIdentifierLocation = false; const exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); - const existing = new Set((namedImportsOrExports.elements as NodeArray).filter(n => !isCurrentlyEditingNode(n)).map(n => (n.propertyName || n.name).escapedText)); + const existing = new Set((namedImportsOrExports.elements as NodeArray).filter(n => !isCurrentlyEditingNode(n)).map(n => moduleExportNameTextEscaped(n.propertyName || n.name))); const uniques = exports.filter(e => e.escapedName !== InternalSymbolName.Default && !existing.has(e.escapedName)); symbols = concatenate(symbols, uniques); if (!uniques.length) { diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 225ad4551ab9e..968a10e62b4aa 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -208,6 +208,8 @@ import { MethodDeclaration, ModifierFlags, ModuleDeclaration, + ModuleExportName, + moduleExportNameIsDefault, MultiMap, NamedDeclaration, Node, @@ -1563,7 +1565,7 @@ export namespace Core { exportingModuleSymbol: Symbol, exportName: string, isDefaultExport: boolean, - cb: (ref: Identifier) => void, + cb: (ref: ModuleExportName) => void, ): void { const importTracker = createImportTracker(sourceFiles, new Set(sourceFiles.map(f => f.fileName)), checker, cancellationToken); const { importSearches, indirectUsers, singleReferences } = importTracker(exportSymbol, { exportKind: isDefaultExport ? ExportKind.Default : ExportKind.Named, exportingModuleSymbol }, /*isForRename*/ false); @@ -1591,9 +1593,9 @@ export namespace Core { if (!hasMatchingMeaning(singleRef, state)) return false; if (state.options.use !== FindReferencesUse.Rename) return true; // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` - if (!isIdentifier(singleRef)) return false; + if (!isIdentifier(singleRef) && !isImportOrExportSpecifier(singleRef.parent)) return false; // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - return !(isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === InternalSymbolName.Default); + return !(isImportOrExportSpecifier(singleRef.parent) && moduleExportNameIsDefault(singleRef)); } // Go to the symbol we imported from and find references for it. @@ -1840,8 +1842,13 @@ export namespace Core { case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.StringLiteral: { const str = node as StringLiteralLike; - return (isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || isNameOfModuleDeclaration(node) || isExpressionOfExternalModuleImportEqualsDeclaration(node) || (isCallExpression(node.parent) && isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && - str.text.length === searchSymbolName.length; + return str.text.length === searchSymbolName.length && ( + isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || + isNameOfModuleDeclaration(node) || + isExpressionOfExternalModuleImportEqualsDeclaration(node) || + (isCallExpression(node.parent) && isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node) || + isImportOrExportSpecifier(node.parent) + ); } case SyntaxKind.NumericLiteral: @@ -1936,8 +1943,8 @@ export namespace Core { } if (isExportSpecifier(parent)) { - Debug.assert(referenceLocation.kind === SyntaxKind.Identifier); - getReferencesAtExportSpecifier(referenceLocation as Identifier, referenceSymbol, parent, search, state, addReferencesHere); + Debug.assert(referenceLocation.kind === SyntaxKind.Identifier || referenceLocation.kind === SyntaxKind.StringLiteral); + getReferencesAtExportSpecifier(referenceLocation as Identifier | StringLiteral, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -1997,7 +2004,7 @@ export namespace Core { } function getReferencesAtExportSpecifier( - referenceLocation: Identifier, + referenceLocation: ModuleExportName, referenceSymbol: Symbol, exportSpecifier: ExportSpecifier, search: Search, @@ -2016,7 +2023,7 @@ export namespace Core { if (!propertyName) { // Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export) - if (!(state.options.use === FindReferencesUse.Rename && (name.escapedText === InternalSymbolName.Default))) { + if (!(state.options.use === FindReferencesUse.Rename && moduleExportNameIsDefault(name))) { addRef(); } } @@ -2039,8 +2046,8 @@ export namespace Core { // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - const isDefaultExport = referenceLocation.escapedText === "default" - || exportSpecifier.name.escapedText === "default"; + const isDefaultExport = moduleExportNameIsDefault(referenceLocation) + || moduleExportNameIsDefault(exportSpecifier.name); const exportKind = isDefaultExport ? ExportKind.Default : ExportKind.Named; const exportSymbol = Debug.checkDefined(exportSpecifier.symbol); const exportInfo = getExportInfo(exportSymbol, exportKind, state.checker); @@ -2060,11 +2067,11 @@ export namespace Core { } } - function getLocalSymbolForExportSpecifier(referenceLocation: Identifier, referenceSymbol: Symbol, exportSpecifier: ExportSpecifier, checker: TypeChecker): Symbol { + function getLocalSymbolForExportSpecifier(referenceLocation: ModuleExportName, referenceSymbol: Symbol, exportSpecifier: ExportSpecifier, checker: TypeChecker): Symbol { return isExportSpecifierAlias(referenceLocation, exportSpecifier) && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) || referenceSymbol; } - function isExportSpecifierAlias(referenceLocation: Identifier, exportSpecifier: ExportSpecifier): boolean { + function isExportSpecifierAlias(referenceLocation: ModuleExportName, exportSpecifier: ExportSpecifier): boolean { const { parent, propertyName, name } = exportSpecifier; Debug.assert(propertyName === referenceLocation || name === referenceLocation); if (propertyName) { diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index a576f684ede54..c1993137ec76e 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -59,6 +59,7 @@ import { isFunctionTypeNode, isIdentifier, isImportMeta, + isImportOrExportSpecifier, isJSDocOverrideTag, isJsxOpeningLikeElement, isJumpStatementTarget, @@ -539,7 +540,12 @@ function getSymbol(node: Node, checker: TypeChecker, stopAtAlias: boolean | unde // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node: Node, declaration: Node): boolean { - if (node.kind !== SyntaxKind.Identifier) { + // Note: Import aliases can be strings: + // + // import { "an alias" as foo } from "./foo"; + // export { foo as "an alias" }; + // + if (node.kind !== SyntaxKind.Identifier && (node.kind !== SyntaxKind.StringLiteral || !isImportOrExportSpecifier(node.parent))) { return false; } if (node.parent === declaration) { diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index ade3cd39edd2a..ab08c18985723 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -62,6 +62,8 @@ import { ModifierFlags, ModuleBlock, ModuleDeclaration, + ModuleExportName, + moduleExportNameTextEscaped, NamedImportsOrExports, NamespaceImport, Node, @@ -90,7 +92,7 @@ import { /** @internal */ export interface ImportsResult { /** For every import of the symbol, the location and local symbol for the import. */ - importSearches: readonly [Identifier, Symbol][]; + importSearches: readonly [ModuleExportName, Symbol][]; /** For rename imports/exports `{ foo as bar }`, `foo` is not a local, so it may be added as a reference immediately without further searching. */ singleReferences: readonly (Identifier | StringLiteral)[]; /** List of source files that may (or may not) use the symbol via a namespace. (For UMD modules this is every file.) */ @@ -319,9 +321,9 @@ function getImportersForExport( * But re-exports will be placed in 'singleReferences' since they cannot be locally referenced. */ function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker, isForRename: boolean): Pick { - const importSearches: [Identifier, Symbol][] = []; + const importSearches: [ModuleExportName, Symbol][] = []; const singleReferences: (Identifier | StringLiteral)[] = []; - function addSearch(location: Identifier, symbol: Symbol): void { + function addSearch(location: ModuleExportName, symbol: Symbol): void { importSearches.push([location, symbol]); } @@ -417,7 +419,7 @@ function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: S for (const element of namedBindings.elements) { const { name, propertyName } = element; - if (!isNameMatch((propertyName || name).escapedText)) { + if (!isNameMatch(moduleExportNameTextEscaped(propertyName || name))) { continue; } @@ -426,7 +428,7 @@ function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: S singleReferences.push(propertyName); // If renaming `{ foo as bar }`, don't touch `bar`, just `foo`. // But do rename `foo` in ` { default as foo }` if that's the original export name. - if (!isForRename || name.escapedText === exportSymbol.escapedName) { + if (!isForRename || moduleExportNameTextEscaped(name) === exportSymbol.escapedName) { // Search locally for `bar`. addSearch(name, checker.getSymbolAtLocation(name)!); } diff --git a/src/services/organizeImports.ts b/src/services/organizeImports.ts index facc06742ded7..a5b366281de57 100644 --- a/src/services/organizeImports.ts +++ b/src/services/organizeImports.ts @@ -45,6 +45,7 @@ import { LanguageServiceHost, length, map, + moduleExportNameTextEscaped, NamedImportBindings, NamedImports, NamespaceImport, @@ -690,7 +691,7 @@ function hasModuleDeclarationMatchingSpecifier(sourceFile: SourceFile, moduleSpe function getNewImportSpecifiers(namedImports: ImportDeclaration[]) { return flatMap(namedImports, namedImport => map(tryGetNamedBindingElements(namedImport), importSpecifier => - importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText + importSpecifier.name && importSpecifier.propertyName && moduleExportNameTextEscaped(importSpecifier.name) === moduleExportNameTextEscaped(importSpecifier.propertyName) ? factory.updateImportSpecifier(importSpecifier, importSpecifier.isTypeOnly, /*propertyName*/ undefined, importSpecifier.name) : importSpecifier)); } diff --git a/src/services/refactors/convertExport.ts b/src/services/refactors/convertExport.ts index 5e722c083a9a0..547403bfb07d0 100644 --- a/src/services/refactors/convertExport.ts +++ b/src/services/refactors/convertExport.ts @@ -34,6 +34,7 @@ import { makeImport, ModifierFlags, ModuleBlock, + ModuleExportName, NamespaceDeclaration, Node, NodeFlags, @@ -236,7 +237,7 @@ function changeImports(program: Program, { wasDefault, exportName, exportingModu }); } -function changeDefaultToNamedImport(importingSourceFile: SourceFile, ref: Identifier, changes: textChanges.ChangeTracker, exportName: string): void { +function changeDefaultToNamedImport(importingSourceFile: SourceFile, ref: ModuleExportName, changes: textChanges.ChangeTracker, exportName: string): void { const { parent } = ref; switch (parent.kind) { case SyntaxKind.PropertyAccessExpression: @@ -282,7 +283,7 @@ function changeDefaultToNamedImport(importingSourceFile: SourceFile, ref: Identi } } -function changeNamedToDefaultImport(importingSourceFile: SourceFile, ref: Identifier, changes: textChanges.ChangeTracker): void { +function changeNamedToDefaultImport(importingSourceFile: SourceFile, ref: ModuleExportName, changes: textChanges.ChangeTracker): void { const parent = ref.parent as PropertyAccessExpression | ImportSpecifier | ExportSpecifier; switch (parent.kind) { case SyntaxKind.PropertyAccessExpression: diff --git a/src/services/refactors/convertImport.ts b/src/services/refactors/convertImport.ts index 55e14b576e1f7..b0071598b3bb7 100644 --- a/src/services/refactors/convertImport.ts +++ b/src/services/refactors/convertImport.ts @@ -247,9 +247,11 @@ export function doChangeNamedToNamespaceOrDefault(sourceFile: SourceFile, progra const neededNamedImports = new Set(); for (const element of toConvert.elements) { - const propertyName = (element.propertyName || element.name).text; + const propertyName = element.propertyName || element.name; FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, id => { - const access = factory.createPropertyAccessExpression(factory.createIdentifier(namespaceImportName), propertyName); + const access = propertyName.kind === SyntaxKind.StringLiteral + ? factory.createElementAccessExpression(factory.createIdentifier(namespaceImportName), factory.cloneNode(propertyName)) + : factory.createPropertyAccessExpression(factory.createIdentifier(namespaceImportName), factory.cloneNode(propertyName)); if (isShorthandPropertyAssignment(id.parent)) { changes.replaceNode(sourceFile, id.parent, factory.createPropertyAssignment(id.text, access)); } @@ -271,7 +273,7 @@ export function doChangeNamedToNamespaceOrDefault(sourceFile: SourceFile, progra ); if (neededNamedImports.size && isImportDeclaration(importDecl)) { - const newNamedImports: ImportSpecifier[] = arrayFrom(neededNamedImports.values(), element => factory.createImportSpecifier(element.isTypeOnly, element.propertyName && factory.createIdentifier(element.propertyName.text), factory.createIdentifier(element.name.text))); + const newNamedImports: ImportSpecifier[] = arrayFrom(neededNamedImports.values(), element => factory.createImportSpecifier(element.isTypeOnly, element.propertyName && factory.cloneNode(element.propertyName), factory.cloneNode(element.name))); changes.insertNodeAfter(sourceFile, toConvert.parent.parent, createImport(importDecl, /*defaultImportName*/ undefined, newNamedImports)); } } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index e6dfbf9200437..0d909d1643d3d 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -5517,7 +5517,7 @@ declare namespace ts { interface NamespaceExport extends NamedDeclaration { readonly kind: SyntaxKind.NamespaceExport; readonly parent: ExportDeclaration; - readonly name: Identifier; + readonly name: ModuleExportName; } interface NamespaceExportDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.NamespaceExportDeclaration; @@ -5549,7 +5549,7 @@ declare namespace ts { interface ImportSpecifier extends NamedDeclaration { readonly kind: SyntaxKind.ImportSpecifier; readonly parent: NamedImports; - readonly propertyName?: Identifier; + readonly propertyName?: ModuleExportName; readonly name: Identifier; readonly isTypeOnly: boolean; } @@ -5557,9 +5557,10 @@ declare namespace ts { readonly kind: SyntaxKind.ExportSpecifier; readonly parent: NamedExports; readonly isTypeOnly: boolean; - readonly propertyName?: Identifier; - readonly name: Identifier; + readonly propertyName?: ModuleExportName; + readonly name: ModuleExportName; } + type ModuleExportName = Identifier | StringLiteral; type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; type TypeOnlyCompatibleAliasDeclaration = ImportClause | ImportEqualsDeclaration | NamespaceImport | ImportOrExportSpecifier | ExportDeclaration | NamespaceExport; type TypeOnlyImportDeclaration = @@ -7661,20 +7662,20 @@ declare namespace ts { updateImportAttribute(node: ImportAttribute, name: ImportAttributeName, value: Expression): ImportAttribute; createNamespaceImport(name: Identifier): NamespaceImport; updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - createNamespaceExport(name: Identifier): NamespaceExport; - updateNamespaceExport(node: NamespaceExport, name: Identifier): NamespaceExport; + createNamespaceExport(name: ModuleExportName): NamespaceExport; + updateNamespaceExport(node: NamespaceExport, name: ModuleExportName): NamespaceExport; createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; - createImportSpecifier(isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + createImportSpecifier(isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier): ImportSpecifier; + updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier): ImportSpecifier; createExportAssignment(modifiers: readonly ModifierLike[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; updateExportAssignment(node: ExportAssignment, modifiers: readonly ModifierLike[] | undefined, expression: Expression): ExportAssignment; createExportDeclaration(modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, attributes?: ImportAttributes): ExportDeclaration; updateExportDeclaration(node: ExportDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, attributes: ImportAttributes | undefined): ExportDeclaration; createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; - createExportSpecifier(isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; - updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; + createExportSpecifier(isTypeOnly: boolean, propertyName: string | ModuleExportName | undefined, name: string | ModuleExportName): ExportSpecifier; + updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: ModuleExportName): ExportSpecifier; createExternalModuleReference(expression: Expression): ExternalModuleReference; updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; createJSDocAllType(): JSDocAllType; @@ -8992,6 +8993,7 @@ declare namespace ts { function isExportDeclaration(node: Node): node is ExportDeclaration; function isNamedExports(node: Node): node is NamedExports; function isExportSpecifier(node: Node): node is ExportSpecifier; + function isModuleExportName(node: Node): node is ModuleExportName; function isMissingDeclaration(node: Node): node is MissingDeclaration; function isNotEmittedStatement(node: Node): node is NotEmittedStatement; function isExternalModuleReference(node: Node): node is ExternalModuleReference; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.errors.txt new file mode 100644 index 0000000000000..40a1073537bb0 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_amd.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_amd.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_amd.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_amd.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.js new file mode 100644 index 0000000000000..297bf6c85ffdb --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.js @@ -0,0 +1,69 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_amd.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_amd.js] +define(["require", "exports", "./arbitraryModuleNamespaceIdentifiers_amd", "./arbitraryModuleNamespaceIdentifiers_amd", "./arbitraryModuleNamespaceIdentifiers_amd", "./arbitraryModuleNamespaceIdentifiers_amd", "./arbitraryModuleNamespaceIdentifiers_amd"], function (require, exports, arbitraryModuleNamespaceIdentifiers_amd_1, arbitraryModuleNamespaceIdentifiers_amd_2, arbitraryModuleNamespaceIdentifiers_amd_3, arbitraryModuleNamespaceIdentifiers_amd_4, arbitraryModuleNamespaceIdentifiers_amd_5) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports[""] = exports[""] = exports[""] = void 0; + const someValue = "someValue"; + exports[""] = someValue; + if (arbitraryModuleNamespaceIdentifiers_amd_1[""] !== "someValue") + throw "should be someValue"; + Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_amd_2[""]; } }); + if (arbitraryModuleNamespaceIdentifiers_amd_3[""] !== "someValue") + throw "should be someValue"; + exports[""] = arbitraryModuleNamespaceIdentifiers_amd_4; + if (arbitraryModuleNamespaceIdentifiers_amd_5[""][""] !== "someValue") + throw "should be someValue"; + if (arbitraryModuleNamespaceIdentifiers_amd_5[""][""] !== "someValue") + throw "should be someValue"; + if (arbitraryModuleNamespaceIdentifiers_amd_5[""][""] !== arbitraryModuleNamespaceIdentifiers_amd_5[""]) + throw "should be export namespace"; + const importTest = "expect error about someType"; + const reimportTest = "expect error about someType"; + const importStarTestA = "expect error about otherType"; +}); + + +//// [arbitraryModuleNamespaceIdentifiers_amd.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.symbols new file mode 100644 index 0000000000000..b45ab00dd143e --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_amd.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 26, 80)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 26, 80)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.types new file mode 100644 index 0000000000000..b536a77b75e89 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_amd.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.errors.txt new file mode 100644 index 0000000000000..288d72e0401c9 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_commonjs.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_commonjs.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_commonjs.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_commonjs.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.js new file mode 100644 index 0000000000000..f6ddaa96a78e5 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.js @@ -0,0 +1,71 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_commonjs.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_commonjs.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports[""] = exports[""] = exports[""] = void 0; +const someValue = "someValue"; +exports[""] = someValue; +const arbitraryModuleNamespaceIdentifiers_commonjs_1 = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); +if (arbitraryModuleNamespaceIdentifiers_commonjs_1[""] !== "someValue") + throw "should be someValue"; +var arbitraryModuleNamespaceIdentifiers_commonjs_2 = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); +Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_commonjs_2[""]; } }); +const arbitraryModuleNamespaceIdentifiers_commonjs_3 = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); +if (arbitraryModuleNamespaceIdentifiers_commonjs_3[""] !== "someValue") + throw "should be someValue"; +exports[""] = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); +const arbitraryModuleNamespaceIdentifiers_commonjs_4 = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); +if (arbitraryModuleNamespaceIdentifiers_commonjs_4[""][""] !== "someValue") + throw "should be someValue"; +if (arbitraryModuleNamespaceIdentifiers_commonjs_4[""][""] !== "someValue") + throw "should be someValue"; +if (arbitraryModuleNamespaceIdentifiers_commonjs_4[""][""] !== arbitraryModuleNamespaceIdentifiers_commonjs_4[""]) + throw "should be export namespace"; +const importTest = "expect error about someType"; +const reimportTest = "expect error about someType"; +const importStarTestA = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_commonjs.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.symbols new file mode 100644 index 0000000000000..607e141116e71 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_commonjs.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 26, 85)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 26, 85)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.types new file mode 100644 index 0000000000000..9ff092140a8f0 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_commonjs.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.errors.txt new file mode 100644 index 0000000000000..f2b9a27149cf3 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.errors.txt @@ -0,0 +1,84 @@ +arbitraryModuleNamespaceIdentifiers_es2015.ts(4,23): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(5,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(8,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(8,19): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(9,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(12,13): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(13,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(18,27): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(19,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(22,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(22,24): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(23,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(26,18): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(27,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_es2015.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_es2015.ts (17 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.js new file mode 100644 index 0000000000000..b646c2549b0bc --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_es2015.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_es2015.js] +const someValue = "someValue"; +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +if (valueX !== "someValue") + throw "should be someValue"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +if (valueY !== "someValue") + throw "should be someValue"; +import * as _a from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export { _a as "" }; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== valueZ) + throw "should be export namespace"; +const importTest = "expect error about someType"; +const reimportTest = "expect error about someType"; +const importStarTestA = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_es2015.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.symbols new file mode 100644 index 0000000000000..52536fcde4470 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_es2015.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.types new file mode 100644 index 0000000000000..5af23a0c08be8 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_es2015.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.errors.txt new file mode 100644 index 0000000000000..2c0d15244f034 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_es2022.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_es2022.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_es2022.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_es2022.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.js new file mode 100644 index 0000000000000..0e388e43056de --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.js @@ -0,0 +1,67 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_es2022.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_es2022.js] +const someValue = "someValue"; +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +if (valueX !== "someValue") + throw "should be someValue"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +if (valueY !== "someValue") + throw "should be someValue"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== valueZ) + throw "should be export namespace"; +const importTest = "expect error about someType"; +const reimportTest = "expect error about someType"; +const importStarTestA = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_es2022.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.symbols new file mode 100644 index 0000000000000..61516af73b8a3 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_es2022.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.types new file mode 100644 index 0000000000000..4455775b0f630 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_es2022.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.errors.txt new file mode 100644 index 0000000000000..b29a1f103c52e --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.errors.txt @@ -0,0 +1,13 @@ +arbitraryModuleNamespaceIdentifiers_exportEmpty.ts(6,7): error TS2322: Type '"empty"' is not assignable to type '"type error expected here"'. + + +==== arbitraryModuleNamespaceIdentifiers_exportEmpty.ts (1 errors) ==== + // This should result in a type error. In particular, the empty string is a now + // a valid module export name, and should be treated as such here. + const empty = "empty"; + export { empty as "" }; + import { "" as foo } from "./arbitraryModuleNamespaceIdentifiers_exportEmpty"; + const bar: "type error expected here" = foo; + ~~~ +!!! error TS2322: Type '"empty"' is not assignable to type '"type error expected here"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.js new file mode 100644 index 0000000000000..a04910b7933be --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_exportEmpty.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_exportEmpty.ts] +// This should result in a type error. In particular, the empty string is a now +// a valid module export name, and should be treated as such here. +const empty = "empty"; +export { empty as "" }; +import { "" as foo } from "./arbitraryModuleNamespaceIdentifiers_exportEmpty"; +const bar: "type error expected here" = foo; + + +//// [arbitraryModuleNamespaceIdentifiers_exportEmpty.js] +// This should result in a type error. In particular, the empty string is a now +// a valid module export name, and should be treated as such here. +const empty = "empty"; +export { empty as "" }; +import { "" as foo } from "./arbitraryModuleNamespaceIdentifiers_exportEmpty"; +const bar = foo; + + +//// [arbitraryModuleNamespaceIdentifiers_exportEmpty.d.ts] +declare const empty = "empty"; +export { empty as "" }; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.symbols new file mode 100644 index 0000000000000..9baebaf89baff --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_exportEmpty.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_exportEmpty.ts === +// This should result in a type error. In particular, the empty string is a now +// a valid module export name, and should be treated as such here. +const empty = "empty"; +>empty : Symbol(empty, Decl(arbitraryModuleNamespaceIdentifiers_exportEmpty.ts, 2, 5)) + +export { empty as "" }; +>empty : Symbol(empty, Decl(arbitraryModuleNamespaceIdentifiers_exportEmpty.ts, 2, 5)) +>"" : Symbol("", Decl(arbitraryModuleNamespaceIdentifiers_exportEmpty.ts, 3, 8)) + +import { "" as foo } from "./arbitraryModuleNamespaceIdentifiers_exportEmpty"; +>foo : Symbol(foo, Decl(arbitraryModuleNamespaceIdentifiers_exportEmpty.ts, 4, 8)) + +const bar: "type error expected here" = foo; +>bar : Symbol(bar, Decl(arbitraryModuleNamespaceIdentifiers_exportEmpty.ts, 5, 5)) +>foo : Symbol(foo, Decl(arbitraryModuleNamespaceIdentifiers_exportEmpty.ts, 4, 8)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.types new file mode 100644 index 0000000000000..d2f63f672fbfb --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_exportEmpty.types @@ -0,0 +1,27 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_exportEmpty.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_exportEmpty.ts === +// This should result in a type error. In particular, the empty string is a now +// a valid module export name, and should be treated as such here. +const empty = "empty"; +>empty : "empty" +> : ^^^^^^^ +>"empty" : "empty" +> : ^^^^^^^ + +export { empty as "" }; +>empty : "empty" +> : ^^^^^^^ +>"" : "empty" +> : ^^^^^^^ + +import { "" as foo } from "./arbitraryModuleNamespaceIdentifiers_exportEmpty"; +>foo : "empty" +> : ^^^^^^^ + +const bar: "type error expected here" = foo; +>bar : "type error expected here" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>foo : "empty" +> : ^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.errors.txt new file mode 100644 index 0000000000000..5f29972f17ae3 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.errors.txt @@ -0,0 +1,21 @@ +arbitraryModuleNamespaceIdentifiers_importEmpty.ts(4,3): error TS2305: Module '"./arbitraryModuleNamespaceIdentifiers_importEmpty"' has no exported member '"missing"'. +arbitraryModuleNamespaceIdentifiers_importEmpty.ts(5,3): error TS2305: Module '"./arbitraryModuleNamespaceIdentifiers_importEmpty"' has no exported member '"(missing)"'. +arbitraryModuleNamespaceIdentifiers_importEmpty.ts(6,3): error TS2305: Module '"./arbitraryModuleNamespaceIdentifiers_importEmpty"' has no exported member '""'. + + +==== arbitraryModuleNamespaceIdentifiers_importEmpty.ts (3 errors) ==== + // These should all be errors. In particular, the empty string is a now a valid + // module export name, and should be treated as such here. + import { + "missing" as x, + ~~~~~~~~~ +!!! error TS2305: Module '"./arbitraryModuleNamespaceIdentifiers_importEmpty"' has no exported member '"missing"'. + "(missing)" as y, + ~~~~~~~~~~~ +!!! error TS2305: Module '"./arbitraryModuleNamespaceIdentifiers_importEmpty"' has no exported member '"(missing)"'. + "" as z, + ~~ +!!! error TS2305: Module '"./arbitraryModuleNamespaceIdentifiers_importEmpty"' has no exported member '""'. + } from "./arbitraryModuleNamespaceIdentifiers_importEmpty"; + const xyz = [x, y, z]; + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.js new file mode 100644 index 0000000000000..4a0e326417031 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_importEmpty.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_importEmpty.ts] +// These should all be errors. In particular, the empty string is a now a valid +// module export name, and should be treated as such here. +import { + "missing" as x, + "(missing)" as y, + "" as z, +} from "./arbitraryModuleNamespaceIdentifiers_importEmpty"; +const xyz = [x, y, z]; + + +//// [arbitraryModuleNamespaceIdentifiers_importEmpty.js] +// These should all be errors. In particular, the empty string is a now a valid +// module export name, and should be treated as such here. +import { "missing" as x, "(missing)" as y, "" as z, } from "./arbitraryModuleNamespaceIdentifiers_importEmpty"; +const xyz = [x, y, z]; + + +//// [arbitraryModuleNamespaceIdentifiers_importEmpty.d.ts] +export {}; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.symbols new file mode 100644 index 0000000000000..663d32df19eae --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.symbols @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_importEmpty.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_importEmpty.ts === +// These should all be errors. In particular, the empty string is a now a valid +// module export name, and should be treated as such here. +import { + "missing" as x, +>x : Symbol(x, Decl(arbitraryModuleNamespaceIdentifiers_importEmpty.ts, 2, 8)) + + "(missing)" as y, +>y : Symbol(y, Decl(arbitraryModuleNamespaceIdentifiers_importEmpty.ts, 3, 17)) + + "" as z, +>z : Symbol(z, Decl(arbitraryModuleNamespaceIdentifiers_importEmpty.ts, 4, 19)) + +} from "./arbitraryModuleNamespaceIdentifiers_importEmpty"; +const xyz = [x, y, z]; +>xyz : Symbol(xyz, Decl(arbitraryModuleNamespaceIdentifiers_importEmpty.ts, 7, 5)) +>x : Symbol(x, Decl(arbitraryModuleNamespaceIdentifiers_importEmpty.ts, 2, 8)) +>y : Symbol(y, Decl(arbitraryModuleNamespaceIdentifiers_importEmpty.ts, 3, 17)) +>z : Symbol(z, Decl(arbitraryModuleNamespaceIdentifiers_importEmpty.ts, 4, 19)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.types new file mode 100644 index 0000000000000..20059408b0e68 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_importEmpty.types @@ -0,0 +1,31 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_importEmpty.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_importEmpty.ts === +// These should all be errors. In particular, the empty string is a now a valid +// module export name, and should be treated as such here. +import { + "missing" as x, +>x : any +> : ^^^ + + "(missing)" as y, +>y : any +> : ^^^ + + "" as z, +>z : any +> : ^^^ + +} from "./arbitraryModuleNamespaceIdentifiers_importEmpty"; +const xyz = [x, y, z]; +>xyz : any[] +> : ^^^^^ +>[x, y, z] : any[] +> : ^^^^^ +>x : any +> : ^^^ +>y : any +> : ^^^ +>z : any +> : ^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.errors.txt new file mode 100644 index 0000000000000..4468d9a48cf1a --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.errors.txt @@ -0,0 +1,70 @@ +types1.ts(10,15): error TS2305: Module '"./types1"' has no exported member '"invalid 1"'. +types1.ts(10,27): error TS1005: 'as' expected. +types1.ts(12,15): error TS1003: Identifier expected. +types2.ts(9,15): error TS2305: Module '"./types2"' has no exported member '"invalid 1"'. +types2.ts(9,27): error TS1005: 'as' expected. +types2.ts(11,15): error TS1003: Identifier expected. +values.ts(10,10): error TS2305: Module '"./values"' has no exported member '"invalid 1"'. +values.ts(10,22): error TS1005: 'as' expected. +values.ts(12,10): error TS1003: Identifier expected. + + +==== values.ts (3 errors) ==== + // Valid + export const foo = 123; + export { foo as "valid 1" }; + import { "valid 1" as bar } from "./values"; + export { "valid 1" as "valid 2" } from "./values"; + export { foo as "valid 3" } from "./values"; + export * as "valid 4" from "./values"; + + // Invalid + import { "invalid 1" } from "./values"; + ~~~~~~~~~~~ +!!! error TS2305: Module '"./values"' has no exported member '"invalid 1"'. + ~ +!!! error TS1005: 'as' expected. + import { foo as "invalid 2" } from "./values"; + export { "invalid 3" as baz }; + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + +==== types1.ts (3 errors) ==== + // Valid + export type foo = 123; + export type { foo as "valid 1" }; + import type { "valid 1" as bar } from "./types1"; + export type { "valid 1" as "valid 2" } from "./types1"; + export type { foo as "valid 3" } from "./types1"; + export type * as "valid 4" from "./types1"; + + // Invalid + import type { "invalid 1" } from "./types1"; + ~~~~~~~~~~~ +!!! error TS2305: Module '"./types1"' has no exported member '"invalid 1"'. + ~ +!!! error TS1005: 'as' expected. + import type { foo as "invalid 2" } from "./types1"; + export type { "invalid 3" as baz }; + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + +==== types2.ts (3 errors) ==== + // Valid + export type foo = 123; + export { type foo as "valid 1" }; + import { type "valid 1" as bar } from "./types2"; + export { type "valid 1" as "valid 2" } from "./types2"; + export { type foo as "valid 3" } from "./types2"; + + // Invalid + import { type "invalid 1" } from "./types2"; + ~~~~~~~~~~~ +!!! error TS2305: Module '"./types2"' has no exported member '"invalid 1"'. + ~ +!!! error TS1005: 'as' expected. + import { type foo as "invalid 2" } from "./types2"; + export { type "invalid 3" as baz }; + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.js new file mode 100644 index 0000000000000..199c018695a71 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.js @@ -0,0 +1,78 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts] //// + +//// [values.ts] +// Valid +export const foo = 123; +export { foo as "valid 1" }; +import { "valid 1" as bar } from "./values"; +export { "valid 1" as "valid 2" } from "./values"; +export { foo as "valid 3" } from "./values"; +export * as "valid 4" from "./values"; + +// Invalid +import { "invalid 1" } from "./values"; +import { foo as "invalid 2" } from "./values"; +export { "invalid 3" as baz }; + +//// [types1.ts] +// Valid +export type foo = 123; +export type { foo as "valid 1" }; +import type { "valid 1" as bar } from "./types1"; +export type { "valid 1" as "valid 2" } from "./types1"; +export type { foo as "valid 3" } from "./types1"; +export type * as "valid 4" from "./types1"; + +// Invalid +import type { "invalid 1" } from "./types1"; +import type { foo as "invalid 2" } from "./types1"; +export type { "invalid 3" as baz }; + +//// [types2.ts] +// Valid +export type foo = 123; +export { type foo as "valid 1" }; +import { type "valid 1" as bar } from "./types2"; +export { type "valid 1" as "valid 2" } from "./types2"; +export { type foo as "valid 3" } from "./types2"; + +// Invalid +import { type "invalid 1" } from "./types2"; +import { type foo as "invalid 2" } from "./types2"; +export { type "invalid 3" as baz }; + + +//// [values.js] +// Valid +export const foo = 123; +export { foo as "valid 1" }; +export { "valid 1" as "valid 2" } from "./values"; +export { foo as "valid 3" } from "./values"; +export * as "valid 4" from "./values"; +export { "invalid 3" as baz }; +//// [types1.js] +export {}; +//// [types2.js] +export {}; + + +//// [values.d.ts] +export declare const foo = 123; +export { foo as "valid 1" }; +export { "valid 1" as "valid 2" } from "./values"; +export { foo as "valid 3" } from "./values"; +export * as "valid 4" from "./values"; +export { "invalid 3" as baz }; +//// [types1.d.ts] +export type foo = 123; +export type { foo as "valid 1" }; +export type { "valid 1" as "valid 2" } from "./types1"; +export type { foo as "valid 3" } from "./types1"; +export type * as "valid 4" from "./types1"; +export type { "invalid 3" as baz }; +//// [types2.d.ts] +export type foo = 123; +export { type foo as "valid 1" }; +export { type "valid 1" as "valid 2" } from "./types2"; +export { type foo as "valid 3" } from "./types2"; +export { type "invalid 3" as baz }; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.symbols new file mode 100644 index 0000000000000..90c4adb5189d8 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.symbols @@ -0,0 +1,98 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts] //// + +=== values.ts === +// Valid +export const foo = 123; +>foo : Symbol(foo, Decl(values.ts, 1, 12)) + +export { foo as "valid 1" }; +>foo : Symbol(foo, Decl(values.ts, 1, 12)) +>"valid 1" : Symbol("valid 1", Decl(values.ts, 2, 8)) + +import { "valid 1" as bar } from "./values"; +>bar : Symbol(bar, Decl(values.ts, 3, 8)) + +export { "valid 1" as "valid 2" } from "./values"; +>"valid 2" : Symbol("valid 2", Decl(values.ts, 4, 8)) + +export { foo as "valid 3" } from "./values"; +>foo : Symbol(foo, Decl(values.ts, 1, 12)) +>"valid 3" : Symbol("valid 3", Decl(values.ts, 5, 8)) + +export * as "valid 4" from "./values"; +>"valid 4" : Symbol("valid 4", Decl(values.ts, 6, 6)) + +// Invalid +import { "invalid 1" } from "./values"; +> : Symbol((Missing), Decl(values.ts, 9, 8)) + +import { foo as "invalid 2" } from "./values"; +>foo : Symbol(foo, Decl(values.ts, 1, 12)) +>"invalid 2" : Symbol("invalid 2", Decl(values.ts, 10, 8)) + +export { "invalid 3" as baz }; +>baz : Symbol(baz, Decl(values.ts, 11, 8)) + +=== types1.ts === +// Valid +export type foo = 123; +>foo : Symbol(foo, Decl(types1.ts, 0, 0)) + +export type { foo as "valid 1" }; +>foo : Symbol(foo, Decl(types1.ts, 0, 0)) +>"valid 1" : Symbol("valid 1", Decl(types1.ts, 2, 13)) + +import type { "valid 1" as bar } from "./types1"; +>bar : Symbol(bar, Decl(types1.ts, 3, 13)) + +export type { "valid 1" as "valid 2" } from "./types1"; +>"valid 2" : Symbol("valid 2", Decl(types1.ts, 4, 13)) + +export type { foo as "valid 3" } from "./types1"; +>foo : Symbol(foo, Decl(types1.ts, 0, 0)) +>"valid 3" : Symbol("valid 3", Decl(types1.ts, 5, 13)) + +export type * as "valid 4" from "./types1"; +>"valid 4" : Symbol("valid 4", Decl(types1.ts, 6, 11)) + +// Invalid +import type { "invalid 1" } from "./types1"; +> : Symbol((Missing), Decl(types1.ts, 9, 13)) + +import type { foo as "invalid 2" } from "./types1"; +>foo : Symbol(foo, Decl(types1.ts, 0, 0)) +>"invalid 2" : Symbol("invalid 2", Decl(types1.ts, 10, 13)) + +export type { "invalid 3" as baz }; +>baz : Symbol(baz, Decl(types1.ts, 11, 13)) + +=== types2.ts === +// Valid +export type foo = 123; +>foo : Symbol(foo, Decl(types2.ts, 0, 0)) + +export { type foo as "valid 1" }; +>foo : Symbol(foo, Decl(types2.ts, 0, 0)) +>"valid 1" : Symbol("valid 1", Decl(types2.ts, 2, 8)) + +import { type "valid 1" as bar } from "./types2"; +>bar : Symbol(bar, Decl(types2.ts, 3, 8)) + +export { type "valid 1" as "valid 2" } from "./types2"; +>"valid 2" : Symbol("valid 2", Decl(types2.ts, 4, 8)) + +export { type foo as "valid 3" } from "./types2"; +>foo : Symbol(foo, Decl(types2.ts, 0, 0)) +>"valid 3" : Symbol("valid 3", Decl(types2.ts, 5, 8)) + +// Invalid +import { type "invalid 1" } from "./types2"; +> : Symbol((Missing), Decl(types2.ts, 8, 8)) + +import { type foo as "invalid 2" } from "./types2"; +>foo : Symbol(foo, Decl(types2.ts, 0, 0)) +>"invalid 2" : Symbol("invalid 2", Decl(types2.ts, 9, 8)) + +export { type "invalid 3" as baz }; +>baz : Symbol(baz, Decl(types2.ts, 10, 8)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.types new file mode 100644 index 0000000000000..ac11b2bfb067e --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.types @@ -0,0 +1,135 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts] //// + +=== values.ts === +// Valid +export const foo = 123; +>foo : 123 +> : ^^^ +>123 : 123 +> : ^^^ + +export { foo as "valid 1" }; +>foo : 123 +> : ^^^ +>"valid 1" : 123 +> : ^^^ + +import { "valid 1" as bar } from "./values"; +>bar : 123 +> : ^^^ + +export { "valid 1" as "valid 2" } from "./values"; +>"valid 2" : 123 +> : ^^^ + +export { foo as "valid 3" } from "./values"; +>foo : 123 +> : ^^^ +>"valid 3" : 123 +> : ^^^ + +export * as "valid 4" from "./values"; +>"valid 4" : typeof import("values") +> : ^^^^^^^^^^^^^^^^^^^^^^^ + +// Invalid +import { "invalid 1" } from "./values"; +> : any +> : ^^^ + +import { foo as "invalid 2" } from "./values"; +>foo : 123 +> : ^^^ +>"invalid 2" : 123 +> : ^^^ + +export { "invalid 3" as baz }; +>baz : any +> : ^^^ + +=== types1.ts === +// Valid +export type foo = 123; +>foo : 123 +> : ^^^ + +export type { foo as "valid 1" }; +>foo : any +> : ^^^ +>"valid 1" : any +> : ^^^ + +import type { "valid 1" as bar } from "./types1"; +>bar : 123 +> : ^^^ + +export type { "valid 1" as "valid 2" } from "./types1"; +>"valid 2" : any +> : ^^^ + +export type { foo as "valid 3" } from "./types1"; +>foo : any +> : ^^^ +>"valid 3" : any +> : ^^^ + +export type * as "valid 4" from "./types1"; +>"valid 4" : typeof import("types1") +> : ^^^^^^^^^^^^^^^^^^^^^^^ + +// Invalid +import type { "invalid 1" } from "./types1"; +> : any +> : ^^^ + +import type { foo as "invalid 2" } from "./types1"; +>foo : any +> : ^^^ +>"invalid 2" : any +> : ^^^ + +export type { "invalid 3" as baz }; +>baz : any +> : ^^^ + +=== types2.ts === +// Valid +export type foo = 123; +>foo : 123 +> : ^^^ + +export { type foo as "valid 1" }; +>foo : any +> : ^^^ +>"valid 1" : any +> : ^^^ + +import { type "valid 1" as bar } from "./types2"; +>bar : any +> : ^^^ + +export { type "valid 1" as "valid 2" } from "./types2"; +>"valid 2" : any +> : ^^^ + +export { type foo as "valid 3" } from "./types2"; +>foo : any +> : ^^^ +>"valid 3" : any +> : ^^^ + +// Invalid +import { type "invalid 1" } from "./types2"; +> : any +> : ^^^ + +import { type foo as "invalid 2" } from "./types2"; +>foo : any +> : ^^^ +>"invalid 2" : any +> : ^^^ + +export { type "invalid 3" as baz }; +>baz : any +> : ^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.errors.txt new file mode 100644 index 0000000000000..3540ebbaa5eda --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_system.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_system.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_system.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_system.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.js new file mode 100644 index 0000000000000..9187258c7e4f9 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.js @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_system.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_system.js] +System.register(["./arbitraryModuleNamespaceIdentifiers_system"], function (exports_1, context_1) { + "use strict"; + var someValue, arbitraryModuleNamespaceIdentifiers_system_1, arbitraryModuleNamespaceIdentifiers_system_2, arbitraryModuleNamespaceIdentifiers_system_3, importTest, reimportTest, importStarTestA; + var __moduleName = context_1 && context_1.id; + return { + setters: [ + function (arbitraryModuleNamespaceIdentifiers_system_1_1) { + arbitraryModuleNamespaceIdentifiers_system_1 = arbitraryModuleNamespaceIdentifiers_system_1_1; + exports_1({ + "": arbitraryModuleNamespaceIdentifiers_system_1_1[""] + }); + arbitraryModuleNamespaceIdentifiers_system_2 = arbitraryModuleNamespaceIdentifiers_system_1_1; + exports_1("", arbitraryModuleNamespaceIdentifiers_system_1_1); + arbitraryModuleNamespaceIdentifiers_system_3 = arbitraryModuleNamespaceIdentifiers_system_1_1; + } + ], + execute: function () { + someValue = "someValue"; + exports_1("", someValue); + if (arbitraryModuleNamespaceIdentifiers_system_1[""] !== "someValue") + throw "should be someValue"; + if (arbitraryModuleNamespaceIdentifiers_system_2[""] !== "someValue") + throw "should be someValue"; + if (arbitraryModuleNamespaceIdentifiers_system_3[""][""] !== "someValue") + throw "should be someValue"; + if (arbitraryModuleNamespaceIdentifiers_system_3[""][""] !== "someValue") + throw "should be someValue"; + if (arbitraryModuleNamespaceIdentifiers_system_3[""][""] !== arbitraryModuleNamespaceIdentifiers_system_3[""]) + throw "should be export namespace"; + importTest = "expect error about someType"; + reimportTest = "expect error about someType"; + importStarTestA = "expect error about otherType"; + } + }; +}); + + +//// [arbitraryModuleNamespaceIdentifiers_system.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.symbols new file mode 100644 index 0000000000000..3ed010475de9f --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_system.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.types new file mode 100644 index 0000000000000..1fca5f6fb7977 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_system.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_types.baseline.jsonc b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_types.baseline.jsonc new file mode 100644 index 0000000000000..544a2769add82 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_types.baseline.jsonc @@ -0,0 +1,1712 @@ +// === findRenameLocations === +// === /foo.ts === +// type foo = "foo"; +// <|export { type foo as "/*RENAME*/[|__RENAME|]" };|> +// <|import { type "[|__RENAME|]" as bar } from "./foo";|> +// const testBar: bar = "foo"; + +// === /bar.ts === +// <|import { type "[|__RENAME|]" as first } from "./foo";|> +// <|export { type "[|__RENAME|]" as "" } from "./foo";|> +// import { type "" as second } from "./bar"; +// const testFirst: first = "foo"; +// const testSecond: second = "foo"; + + + +// === findRenameLocations === +// === /foo.ts === +// type foo = "foo"; +// <|export { type foo as "[|__RENAME|]" };|> +// <|import { type "/*RENAME*/[|__RENAME|]" as bar } from "./foo";|> +// const testBar: bar = "foo"; + +// === /bar.ts === +// <|import { type "[|__RENAME|]" as first } from "./foo";|> +// <|export { type "[|__RENAME|]" as "" } from "./foo";|> +// import { type "" as second } from "./bar"; +// const testFirst: first = "foo"; +// const testSecond: second = "foo"; + + + +// === findRenameLocations === +// === /foo.ts === +// type foo = "foo"; +// <|export { type foo as "[|__RENAME|]" };|> +// <|import { type "[|__RENAME|]" as bar } from "./foo";|> +// const testBar: bar = "foo"; + +// === /bar.ts === +// <|import { type "/*RENAME*/[|__RENAME|]" as first } from "./foo";|> +// <|export { type "[|__RENAME|]" as "" } from "./foo";|> +// import { type "" as second } from "./bar"; +// const testFirst: first = "foo"; +// const testSecond: second = "foo"; + + + +// === findRenameLocations === +// === /foo.ts === +// type foo = "foo"; +// <|export { type foo as "[|__RENAME|]" };|> +// <|import { type "[|__RENAME|]" as bar } from "./foo";|> +// const testBar: bar = "foo"; + +// === /bar.ts === +// <|import { type "[|__RENAME|]" as first } from "./foo";|> +// <|export { type "/*RENAME*/[|__RENAME|]" as "" } from "./foo";|> +// import { type "" as second } from "./bar"; +// const testFirst: first = "foo"; +// const testSecond: second = "foo"; + + + +// === goToDefinition === +// === /foo.ts === +// <|type [|foo|] = "foo";|> +// export { type foo as "/*GOTO DEF*/__" }; +// import { type "__" as bar } from "./foo"; +// const testBar: bar = "foo"; + + // === Details === + [ + { + "kind": "type", + "name": "foo", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /foo.ts === +// <|type [|foo|] = "foo";|> +// export { type foo as "__" }; +// import { type "/*GOTO DEF*/__" as bar } from "./foo"; +// const testBar: bar = "foo"; + + // === Details === + [ + { + "kind": "type", + "name": "foo", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /foo.ts === +// <|type [|foo|] = "foo";|> +// export { type foo as "__" }; +// import { type "__" as bar } from "./foo"; +// const testBar: bar = "foo"; + +// === /bar.ts === +// import { type [|"/*GOTO DEF*/__"|] as first } from "./foo"; +// export { type "__" as "" } from "./foo"; +// import { type "" as second } from "./bar"; +// const testFirst: first = "foo"; +// const testSecond: second = "foo"; + + // === Details === + [ + { + "kind": "type", + "name": "foo", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /foo.ts === +// <|type [|foo|] = "foo";|> +// export { type foo as "__" }; +// import { type "__" as bar } from "./foo"; +// const testBar: bar = "foo"; + +// === /bar.ts === +// import { type "__" as first } from "./foo"; +// export { type [|"/*GOTO DEF*/__"|] as "" } from "./foo"; +// import { type "" as second } from "./bar"; +// const testFirst: first = "foo"; +// const testSecond: second = "foo"; + + // === Details === + [ + { + "kind": "type", + "name": "foo", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === findAllReferences === +// === /foo.ts === +// type foo = "foo"; +// <|export { type foo as "/*FIND ALL REFS*/[|{| defId: 0, isWriteAccess: true, isDefinition: true |}__|]" };|> +// <|<|import { type "[|{| contextId: 1, defId: 0 |}__|]" as [|{| contextId: 2, defId: 1, isWriteAccess: true |}bar|] } from "./foo";|>|> +// const testBar: [|{| defId: 1 |}bar|] = "foo"; + +// === /bar.ts === +// <|<|import { type "[|{| contextId: 3, defId: 0 |}__|]" as [|{| contextId: 4, defId: 2, isWriteAccess: true |}first|] } from "./foo";|>|> +// <|<|export { type "[|{| contextId: 5, defId: 0 |}__|]" as "[|{| contextId: 6, defId: 3, isWriteAccess: true |}|]" } from "./foo";|>|> +// <|<|import { type "[|{| contextId: 7, defId: 3 |}|]" as [|{| contextId: 8, defId: 4, isWriteAccess: true |}second|] } from "./bar";|>|> +// const testFirst: [|{| defId: 2 |}first|] = "foo"; +// const testSecond: [|{| defId: 4 |}second|] = "foo"; + + // === Definitions === + // === /foo.ts === + // type foo = "foo"; + // <|export { type foo as "/*FIND ALL REFS*/[|{| defId: 0 |}__|]" };|> + // <|import { type "__" as [|{| defId: 1 |}bar|] } from "./foo";|> + // const testBar: bar = "foo"; + + // === /bar.ts === + // <|import { type "__" as [|{| defId: 2 |}first|] } from "./foo";|> + // <|export { type "__" as "[|{| defId: 3 |}|]" } from "./foo";|> + // <|import { type "" as [|{| defId: 4 |}second|] } from "./bar";|> + // const testFirst: first = "foo"; + // const testSecond: second = "foo"; + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type \"__\" = \"foo\"\nexport \"__\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type bar = \"foo\"\nimport bar", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + } + ] + }, + { + "defId": 2, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type first = \"foo\"\nimport first", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + } + ] + }, + { + "defId": 3, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type \"\" = \"foo\"\nexport \"\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 4, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type second = \"foo\"\nimport second", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /foo.ts === +// type foo = "foo"; +// <|export { type foo as "[|{| defId: 0, isWriteAccess: true |}__|]" };|> +// <|<|import { type "/*FIND ALL REFS*/[|{| contextId: 1, defId: 0 |}__|]" as [|{| contextId: 2, defId: 1, isWriteAccess: true |}bar|] } from "./foo";|>|> +// const testBar: [|{| defId: 1 |}bar|] = "foo"; + +// === /bar.ts === +// <|<|import { type "[|{| contextId: 3, defId: 0 |}__|]" as [|{| contextId: 4, defId: 2, isWriteAccess: true |}first|] } from "./foo";|>|> +// <|<|export { type "[|{| contextId: 5, defId: 0 |}__|]" as "[|{| contextId: 6, defId: 3, isWriteAccess: true |}|]" } from "./foo";|>|> +// <|<|import { type "[|{| contextId: 7, defId: 3 |}|]" as [|{| contextId: 8, defId: 4, isWriteAccess: true |}second|] } from "./bar";|>|> +// const testFirst: [|{| defId: 2 |}first|] = "foo"; +// const testSecond: [|{| defId: 4 |}second|] = "foo"; + + // === Definitions === + // === /foo.ts === + // type foo = "foo"; + // <|export { type foo as "[|{| defId: 0 |}__|]" };|> + // <|import { type "/*FIND ALL REFS*/__" as [|{| defId: 1 |}bar|] } from "./foo";|> + // const testBar: bar = "foo"; + + // === /bar.ts === + // <|import { type "__" as [|{| defId: 2 |}first|] } from "./foo";|> + // <|export { type "__" as "[|{| defId: 3 |}|]" } from "./foo";|> + // <|import { type "" as [|{| defId: 4 |}second|] } from "./bar";|> + // const testFirst: first = "foo"; + // const testSecond: second = "foo"; + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type \"__\" = \"foo\"\nexport \"__\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type bar = \"foo\"\nimport bar", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + } + ] + }, + { + "defId": 2, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type first = \"foo\"\nimport first", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + } + ] + }, + { + "defId": 3, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type \"\" = \"foo\"\nexport \"\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 4, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type second = \"foo\"\nimport second", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /foo.ts === +// type foo = "foo"; +// <|export { type foo as "[|{| defId: 0, isWriteAccess: true |}__|]" };|> +// <|<|import { type "[|{| contextId: 1, defId: 0 |}__|]" as [|{| contextId: 2, defId: 1, isWriteAccess: true |}bar|] } from "./foo";|>|> +// const testBar: [|{| defId: 1 |}bar|] = "foo"; + +// === /bar.ts === +// <|<|import { type "/*FIND ALL REFS*/[|{| contextId: 3, defId: 0 |}__|]" as [|{| contextId: 4, defId: 2, isWriteAccess: true |}first|] } from "./foo";|>|> +// <|<|export { type "[|{| contextId: 5, defId: 0 |}__|]" as "[|{| contextId: 6, defId: 3, isWriteAccess: true |}|]" } from "./foo";|>|> +// <|<|import { type "[|{| contextId: 7, defId: 3 |}|]" as [|{| contextId: 8, defId: 4, isWriteAccess: true |}second|] } from "./bar";|>|> +// const testFirst: [|{| defId: 2 |}first|] = "foo"; +// const testSecond: [|{| defId: 4 |}second|] = "foo"; + + // === Definitions === + // === /foo.ts === + // type foo = "foo"; + // <|export { type foo as "[|{| defId: 0 |}__|]" };|> + // <|import { type "__" as [|{| defId: 1 |}bar|] } from "./foo";|> + // const testBar: bar = "foo"; + + // === /bar.ts === + // <|import { type "/*FIND ALL REFS*/__" as [|{| defId: 2 |}first|] } from "./foo";|> + // <|export { type "__" as "[|{| defId: 3 |}|]" } from "./foo";|> + // <|import { type "" as [|{| defId: 4 |}second|] } from "./bar";|> + // const testFirst: first = "foo"; + // const testSecond: second = "foo"; + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type \"__\" = \"foo\"\nexport \"__\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type bar = \"foo\"\nimport bar", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + } + ] + }, + { + "defId": 2, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type first = \"foo\"\nimport first", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + } + ] + }, + { + "defId": 3, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type \"\" = \"foo\"\nexport \"\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 4, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type second = \"foo\"\nimport second", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /foo.ts === +// <|type [|{| defId: 0, isWriteAccess: true |}foo|] = "foo";|> +// <|<|export { type [|{| contextId: 1, defId: 0 |}foo|] as "[|{| contextId: 2, defId: 1, isWriteAccess: true |}__|]" };|>|> +// <|<|import { type "[|{| contextId: 3, defId: 1 |}__|]" as [|{| contextId: 4, defId: 2, isWriteAccess: true |}bar|] } from "./foo";|>|> +// const testBar: [|{| defId: 2 |}bar|] = "foo"; + +// === /bar.ts === +// <|<|import { type "[|{| contextId: 5, defId: 1 |}__|]" as [|{| contextId: 6, defId: 3, isWriteAccess: true |}first|] } from "./foo";|>|> +// <|<|export { type "/*FIND ALL REFS*/[|{| contextId: 7, defId: 1 |}__|]" as "[|{| contextId: 8, defId: 4, isWriteAccess: true |}|]" } from "./foo";|>|> +// <|<|import { type "[|{| contextId: 9, defId: 4 |}|]" as [|{| contextId: 10, defId: 5, isWriteAccess: true |}second|] } from "./bar";|>|> +// const testFirst: [|{| defId: 3 |}first|] = "foo"; +// const testSecond: [|{| defId: 5 |}second|] = "foo"; + + // === Definitions === + // === /foo.ts === + // <|type [|{| defId: 0 |}foo|] = "foo";|> + // <|export { type foo as "[|{| defId: 1 |}__|]" };|> + // <|import { type "__" as [|{| defId: 2 |}bar|] } from "./foo";|> + // const testBar: bar = "foo"; + + // === /bar.ts === + // <|import { type "__" as [|{| defId: 3 |}first|] } from "./foo";|> + // <|export { type "/*FIND ALL REFS*/__" as "[|{| defId: 4 |}|]" } from "./foo";|> + // <|import { type "" as [|{| defId: 5 |}second|] } from "./bar";|> + // const testFirst: first = "foo"; + // const testSecond: second = "foo"; + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "type", + "name": "type foo = \"foo\"", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type \"__\" = \"foo\"\nexport \"__\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 2, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type bar = \"foo\"\nimport bar", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + } + ] + }, + { + "defId": 3, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type first = \"foo\"\nimport first", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + } + ] + }, + { + "defId": 4, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type \"\" = \"foo\"\nexport \"\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 5, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) type second = \"foo\"\nimport second", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + } + ] + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.errors.txt new file mode 100644 index 0000000000000..364e2a6b3eb63 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_umd.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_umd.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_umd.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_umd.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.js new file mode 100644 index 0000000000000..045b5428f0621 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.js @@ -0,0 +1,81 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_umd.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_umd.js] +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define(["require", "exports", "./arbitraryModuleNamespaceIdentifiers_umd", "./arbitraryModuleNamespaceIdentifiers_umd", "./arbitraryModuleNamespaceIdentifiers_umd", "./arbitraryModuleNamespaceIdentifiers_umd", "./arbitraryModuleNamespaceIdentifiers_umd"], factory); + } +})(function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports[""] = exports[""] = exports[""] = void 0; + const someValue = "someValue"; + exports[""] = someValue; + const arbitraryModuleNamespaceIdentifiers_umd_1 = require("./arbitraryModuleNamespaceIdentifiers_umd"); + if (arbitraryModuleNamespaceIdentifiers_umd_1[""] !== "someValue") + throw "should be someValue"; + var arbitraryModuleNamespaceIdentifiers_umd_2 = require("./arbitraryModuleNamespaceIdentifiers_umd"); + Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_umd_2[""]; } }); + const arbitraryModuleNamespaceIdentifiers_umd_3 = require("./arbitraryModuleNamespaceIdentifiers_umd"); + if (arbitraryModuleNamespaceIdentifiers_umd_3[""] !== "someValue") + throw "should be someValue"; + exports[""] = require("./arbitraryModuleNamespaceIdentifiers_umd"); + const arbitraryModuleNamespaceIdentifiers_umd_4 = require("./arbitraryModuleNamespaceIdentifiers_umd"); + if (arbitraryModuleNamespaceIdentifiers_umd_4[""][""] !== "someValue") + throw "should be someValue"; + if (arbitraryModuleNamespaceIdentifiers_umd_4[""][""] !== "someValue") + throw "should be someValue"; + if (arbitraryModuleNamespaceIdentifiers_umd_4[""][""] !== arbitraryModuleNamespaceIdentifiers_umd_4[""]) + throw "should be export namespace"; + const importTest = "expect error about someType"; + const reimportTest = "expect error about someType"; + const importStarTestA = "expect error about otherType"; +}); + + +//// [arbitraryModuleNamespaceIdentifiers_umd.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.symbols new file mode 100644 index 0000000000000..9836582e00955 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_umd.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 26, 80)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 26, 80)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.types new file mode 100644 index 0000000000000..7afb929842d69 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_umd.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_values.baseline.jsonc b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_values.baseline.jsonc new file mode 100644 index 0000000000000..a992bc70499ea --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_values.baseline.jsonc @@ -0,0 +1,1628 @@ +// === findRenameLocations === +// === /foo.ts === +// const foo = "foo"; +// <|export { foo as "/*RENAME*/[|__RENAME|]" };|> +// <|import { "[|__RENAME|]" as bar } from "./foo";|> +// if (bar !== "foo") throw bar; + +// === /bar.ts === +// <|import { "[|__RENAME|]" as first } from "./foo";|> +// <|export { "[|__RENAME|]" as "" } from "./foo";|> +// import { "" as second } from "./bar"; +// if (first !== "foo") throw first; +// if (second !== "foo") throw second; + + + +// === findRenameLocations === +// === /foo.ts === +// const foo = "foo"; +// <|export { foo as "[|__RENAME|]" };|> +// <|import { "/*RENAME*/[|__RENAME|]" as bar } from "./foo";|> +// if (bar !== "foo") throw bar; + +// === /bar.ts === +// <|import { "[|__RENAME|]" as first } from "./foo";|> +// <|export { "[|__RENAME|]" as "" } from "./foo";|> +// import { "" as second } from "./bar"; +// if (first !== "foo") throw first; +// if (second !== "foo") throw second; + + + +// === findRenameLocations === +// === /foo.ts === +// const foo = "foo"; +// <|export { foo as "[|__RENAME|]" };|> +// <|import { "[|__RENAME|]" as bar } from "./foo";|> +// if (bar !== "foo") throw bar; + +// === /bar.ts === +// <|import { "/*RENAME*/[|__RENAME|]" as first } from "./foo";|> +// <|export { "[|__RENAME|]" as "" } from "./foo";|> +// import { "" as second } from "./bar"; +// if (first !== "foo") throw first; +// if (second !== "foo") throw second; + + + +// === findRenameLocations === +// === /foo.ts === +// const foo = "foo"; +// <|export { foo as "[|__RENAME|]" };|> +// <|import { "[|__RENAME|]" as bar } from "./foo";|> +// if (bar !== "foo") throw bar; + +// === /bar.ts === +// <|import { "[|__RENAME|]" as first } from "./foo";|> +// <|export { "/*RENAME*/[|__RENAME|]" as "" } from "./foo";|> +// import { "" as second } from "./bar"; +// if (first !== "foo") throw first; +// if (second !== "foo") throw second; + + + +// === goToDefinition === +// === /foo.ts === +// <|const [|foo|] = "foo";|> +// export { foo as "/*GOTO DEF*/__" }; +// import { "__" as bar } from "./foo"; +// if (bar !== "foo") throw bar; + + // === Details === + [ + { + "kind": "const", + "name": "foo", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /foo.ts === +// <|const [|foo|] = "foo";|> +// export { foo as "__" }; +// import { "/*GOTO DEF*/__" as bar } from "./foo"; +// if (bar !== "foo") throw bar; + + // === Details === + [ + { + "kind": "const", + "name": "foo", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /foo.ts === +// <|const [|foo|] = "foo";|> +// export { foo as "__" }; +// import { "__" as bar } from "./foo"; +// if (bar !== "foo") throw bar; + +// === /bar.ts === +// import { [|"/*GOTO DEF*/__"|] as first } from "./foo"; +// export { "__" as "" } from "./foo"; +// import { "" as second } from "./bar"; +// if (first !== "foo") throw first; +// if (second !== "foo") throw second; + + // === Details === + [ + { + "kind": "const", + "name": "foo", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /foo.ts === +// <|const [|foo|] = "foo";|> +// export { foo as "__" }; +// import { "__" as bar } from "./foo"; +// if (bar !== "foo") throw bar; + +// === /bar.ts === +// import { "__" as first } from "./foo"; +// export { [|"/*GOTO DEF*/__"|] as "" } from "./foo"; +// import { "" as second } from "./bar"; +// if (first !== "foo") throw first; +// if (second !== "foo") throw second; + + // === Details === + [ + { + "kind": "const", + "name": "foo", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === findAllReferences === +// === /foo.ts === +// const foo = "foo"; +// <|export { foo as "/*FIND ALL REFS*/[|{| defId: 0, isWriteAccess: true, isDefinition: true |}__|]" };|> +// <|<|import { "[|{| contextId: 1, defId: 0 |}__|]" as [|{| contextId: 2, defId: 1, isWriteAccess: true |}bar|] } from "./foo";|>|> +// if ([|{| defId: 1 |}bar|] !== "foo") throw [|{| defId: 1 |}bar|]; + +// === /bar.ts === +// <|<|import { "[|{| contextId: 3, defId: 0 |}__|]" as [|{| contextId: 4, defId: 2, isWriteAccess: true |}first|] } from "./foo";|>|> +// <|<|export { "[|{| contextId: 5, defId: 0 |}__|]" as "[|{| contextId: 6, defId: 3, isWriteAccess: true |}|]" } from "./foo";|>|> +// <|<|import { "[|{| contextId: 7, defId: 3 |}|]" as [|{| contextId: 8, defId: 4, isWriteAccess: true |}second|] } from "./bar";|>|> +// if ([|{| defId: 2 |}first|] !== "foo") throw [|{| defId: 2 |}first|]; +// if ([|{| defId: 4 |}second|] !== "foo") throw [|{| defId: 4 |}second|]; + + // === Definitions === + // === /foo.ts === + // const foo = "foo"; + // <|export { foo as "/*FIND ALL REFS*/[|{| defId: 0 |}__|]" };|> + // <|import { "__" as [|{| defId: 1 |}bar|] } from "./foo";|> + // if (bar !== "foo") throw bar; + + // === /bar.ts === + // <|import { "__" as [|{| defId: 2 |}first|] } from "./foo";|> + // <|export { "__" as "[|{| defId: 3 |}|]" } from "./foo";|> + // <|import { "" as [|{| defId: 4 |}second|] } from "./bar";|> + // if (first !== "foo") throw first; + // if (second !== "foo") throw second; + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const \"__\": \"foo\"\nexport \"__\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const bar: \"foo\"\nimport bar", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + } + ] + }, + { + "defId": 2, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const first: \"foo\"\nimport first", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + } + ] + }, + { + "defId": 3, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const \"\": \"foo\"\nexport \"\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 4, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const second: \"foo\"\nimport second", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /foo.ts === +// const foo = "foo"; +// <|export { foo as "[|{| defId: 0, isWriteAccess: true |}__|]" };|> +// <|<|import { "/*FIND ALL REFS*/[|{| contextId: 1, defId: 0 |}__|]" as [|{| contextId: 2, defId: 1, isWriteAccess: true |}bar|] } from "./foo";|>|> +// if ([|{| defId: 1 |}bar|] !== "foo") throw [|{| defId: 1 |}bar|]; + +// === /bar.ts === +// <|<|import { "[|{| contextId: 3, defId: 0 |}__|]" as [|{| contextId: 4, defId: 2, isWriteAccess: true |}first|] } from "./foo";|>|> +// <|<|export { "[|{| contextId: 5, defId: 0 |}__|]" as "[|{| contextId: 6, defId: 3, isWriteAccess: true |}|]" } from "./foo";|>|> +// <|<|import { "[|{| contextId: 7, defId: 3 |}|]" as [|{| contextId: 8, defId: 4, isWriteAccess: true |}second|] } from "./bar";|>|> +// if ([|{| defId: 2 |}first|] !== "foo") throw [|{| defId: 2 |}first|]; +// if ([|{| defId: 4 |}second|] !== "foo") throw [|{| defId: 4 |}second|]; + + // === Definitions === + // === /foo.ts === + // const foo = "foo"; + // <|export { foo as "[|{| defId: 0 |}__|]" };|> + // <|import { "/*FIND ALL REFS*/__" as [|{| defId: 1 |}bar|] } from "./foo";|> + // if (bar !== "foo") throw bar; + + // === /bar.ts === + // <|import { "__" as [|{| defId: 2 |}first|] } from "./foo";|> + // <|export { "__" as "[|{| defId: 3 |}|]" } from "./foo";|> + // <|import { "" as [|{| defId: 4 |}second|] } from "./bar";|> + // if (first !== "foo") throw first; + // if (second !== "foo") throw second; + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const \"__\": \"foo\"\nexport \"__\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const bar: \"foo\"\nimport bar", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + } + ] + }, + { + "defId": 2, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const first: \"foo\"\nimport first", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + } + ] + }, + { + "defId": 3, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const \"\": \"foo\"\nexport \"\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 4, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const second: \"foo\"\nimport second", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /foo.ts === +// const foo = "foo"; +// <|export { foo as "[|{| defId: 0, isWriteAccess: true |}__|]" };|> +// <|<|import { "[|{| contextId: 1, defId: 0 |}__|]" as [|{| contextId: 2, defId: 1, isWriteAccess: true |}bar|] } from "./foo";|>|> +// if ([|{| defId: 1 |}bar|] !== "foo") throw [|{| defId: 1 |}bar|]; + +// === /bar.ts === +// <|<|import { "/*FIND ALL REFS*/[|{| contextId: 3, defId: 0 |}__|]" as [|{| contextId: 4, defId: 2, isWriteAccess: true |}first|] } from "./foo";|>|> +// <|<|export { "[|{| contextId: 5, defId: 0 |}__|]" as "[|{| contextId: 6, defId: 3, isWriteAccess: true |}|]" } from "./foo";|>|> +// <|<|import { "[|{| contextId: 7, defId: 3 |}|]" as [|{| contextId: 8, defId: 4, isWriteAccess: true |}second|] } from "./bar";|>|> +// if ([|{| defId: 2 |}first|] !== "foo") throw [|{| defId: 2 |}first|]; +// if ([|{| defId: 4 |}second|] !== "foo") throw [|{| defId: 4 |}second|]; + + // === Definitions === + // === /foo.ts === + // const foo = "foo"; + // <|export { foo as "[|{| defId: 0 |}__|]" };|> + // <|import { "__" as [|{| defId: 1 |}bar|] } from "./foo";|> + // if (bar !== "foo") throw bar; + + // === /bar.ts === + // <|import { "/*FIND ALL REFS*/__" as [|{| defId: 2 |}first|] } from "./foo";|> + // <|export { "__" as "[|{| defId: 3 |}|]" } from "./foo";|> + // <|import { "" as [|{| defId: 4 |}second|] } from "./bar";|> + // if (first !== "foo") throw first; + // if (second !== "foo") throw second; + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const \"__\": \"foo\"\nexport \"__\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const bar: \"foo\"\nimport bar", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + } + ] + }, + { + "defId": 2, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const first: \"foo\"\nimport first", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + } + ] + }, + { + "defId": 3, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const \"\": \"foo\"\nexport \"\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 4, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const second: \"foo\"\nimport second", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /foo.ts === +// <|const [|{| defId: 0, isWriteAccess: true |}foo|] = "foo";|> +// <|<|export { [|{| contextId: 1, defId: 0 |}foo|] as "[|{| contextId: 2, defId: 1, isWriteAccess: true |}__|]" };|>|> +// <|<|import { "[|{| contextId: 3, defId: 1 |}__|]" as [|{| contextId: 4, defId: 2, isWriteAccess: true |}bar|] } from "./foo";|>|> +// if ([|{| defId: 2 |}bar|] !== "foo") throw [|{| defId: 2 |}bar|]; + +// === /bar.ts === +// <|<|import { "[|{| contextId: 5, defId: 1 |}__|]" as [|{| contextId: 6, defId: 3, isWriteAccess: true |}first|] } from "./foo";|>|> +// <|<|export { "/*FIND ALL REFS*/[|{| contextId: 7, defId: 1 |}__|]" as "[|{| contextId: 8, defId: 4, isWriteAccess: true |}|]" } from "./foo";|>|> +// <|<|import { "[|{| contextId: 9, defId: 4 |}|]" as [|{| contextId: 10, defId: 5, isWriteAccess: true |}second|] } from "./bar";|>|> +// if ([|{| defId: 3 |}first|] !== "foo") throw [|{| defId: 3 |}first|]; +// if ([|{| defId: 5 |}second|] !== "foo") throw [|{| defId: 5 |}second|]; + + // === Definitions === + // === /foo.ts === + // <|const [|{| defId: 0 |}foo|] = "foo";|> + // <|export { foo as "[|{| defId: 1 |}__|]" };|> + // <|import { "__" as [|{| defId: 2 |}bar|] } from "./foo";|> + // if (bar !== "foo") throw bar; + + // === /bar.ts === + // <|import { "__" as [|{| defId: 3 |}first|] } from "./foo";|> + // <|export { "/*FIND ALL REFS*/__" as "[|{| defId: 4 |}|]" } from "./foo";|> + // <|import { "" as [|{| defId: 5 |}second|] } from "./bar";|> + // if (first !== "foo") throw first; + // if (second !== "foo") throw second; + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "const", + "name": "const foo: \"foo\"", + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + } + ] + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const \"__\": \"foo\"\nexport \"__\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"__\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 2, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const bar: \"foo\"\nimport bar", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "aliasName" + } + ] + }, + { + "defId": 3, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const first: \"foo\"\nimport first", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "first", + "kind": "aliasName" + } + ] + }, + { + "defId": 4, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const \"\": \"foo\"\nexport \"\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"\"", + "kind": "aliasName" + } + ] + }, + { + "defId": 5, + "containerKind": "", + "containerName": "", + "kind": "alias", + "name": "(alias) const second: \"foo\"\nimport second", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "second", + "kind": "aliasName" + } + ] + } + ] \ No newline at end of file diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts new file mode 100644 index 0000000000000..bb2c6113b07b0 --- /dev/null +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts @@ -0,0 +1,33 @@ +//@module: AMD +//@target: ES2022 +//@declaration: true + +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts new file mode 100644 index 0000000000000..b94b5cc978eb5 --- /dev/null +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts @@ -0,0 +1,33 @@ +//@module: CommonJS +//@target: ES2022 +//@declaration: true + +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts new file mode 100644 index 0000000000000..fbe39ff6aea8e --- /dev/null +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts @@ -0,0 +1,33 @@ +//@module: ES2015 +//@target: ESNext +//@declaration: true + +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts new file mode 100644 index 0000000000000..3eb638d398d38 --- /dev/null +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts @@ -0,0 +1,33 @@ +//@module: ES2022 +//@target: ES2022 +//@declaration: true + +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_exportEmpty.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_exportEmpty.ts new file mode 100644 index 0000000000000..2f1d66936aaf1 --- /dev/null +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_exportEmpty.ts @@ -0,0 +1,10 @@ +//@module: ES2022 +//@target: ES2022 +//@declaration: true + +// This should result in a type error. In particular, the empty string is a now +// a valid module export name, and should be treated as such here. +const empty = "empty"; +export { empty as "" }; +import { "" as foo } from "./arbitraryModuleNamespaceIdentifiers_exportEmpty"; +const bar: "type error expected here" = foo; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_importEmpty.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_importEmpty.ts new file mode 100644 index 0000000000000..42023ae4411f8 --- /dev/null +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_importEmpty.ts @@ -0,0 +1,12 @@ +//@module: ES2022 +//@target: ES2022 +//@declaration: true + +// These should all be errors. In particular, the empty string is a now a valid +// module export name, and should be treated as such here. +import { + "missing" as x, + "(missing)" as y, + "" as z, +} from "./arbitraryModuleNamespaceIdentifiers_importEmpty"; +const xyz = [x, y, z]; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts new file mode 100644 index 0000000000000..0c8e3f84c216e --- /dev/null +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts @@ -0,0 +1,47 @@ +//@module: ES2022 +//@target: ES2022 +//@declaration: true + +// @filename: values.ts + +// Valid +export const foo = 123; +export { foo as "valid 1" }; +import { "valid 1" as bar } from "./values"; +export { "valid 1" as "valid 2" } from "./values"; +export { foo as "valid 3" } from "./values"; +export * as "valid 4" from "./values"; + +// Invalid +import { "invalid 1" } from "./values"; +import { foo as "invalid 2" } from "./values"; +export { "invalid 3" as baz }; + +// @filename: types1.ts + +// Valid +export type foo = 123; +export type { foo as "valid 1" }; +import type { "valid 1" as bar } from "./types1"; +export type { "valid 1" as "valid 2" } from "./types1"; +export type { foo as "valid 3" } from "./types1"; +export type * as "valid 4" from "./types1"; + +// Invalid +import type { "invalid 1" } from "./types1"; +import type { foo as "invalid 2" } from "./types1"; +export type { "invalid 3" as baz }; + +// @filename: types2.ts + +// Valid +export type foo = 123; +export { type foo as "valid 1" }; +import { type "valid 1" as bar } from "./types2"; +export { type "valid 1" as "valid 2" } from "./types2"; +export { type foo as "valid 3" } from "./types2"; + +// Invalid +import { type "invalid 1" } from "./types2"; +import { type foo as "invalid 2" } from "./types2"; +export { type "invalid 3" as baz }; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts new file mode 100644 index 0000000000000..ffbcf600faf99 --- /dev/null +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts @@ -0,0 +1,33 @@ +//@module: System +//@target: ES2022 +//@declaration: true + +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts new file mode 100644 index 0000000000000..749a288bfe905 --- /dev/null +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts @@ -0,0 +1,33 @@ +//@module: UMD +//@target: ES2022 +//@declaration: true + +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_types.ts b/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_types.ts new file mode 100644 index 0000000000000..be380d0d590da --- /dev/null +++ b/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_types.ts @@ -0,0 +1,19 @@ +/// + +// @Filename: /foo.ts +////type foo = "foo"; +////export { type foo as "[|__|]" }; +////import { type "[|__|]" as bar } from "./foo"; +////const testBar: bar = "foo"; + +// @Filename: /bar.ts +////import { type "[|__|]" as first } from "./foo"; +////export { type "[|__|]" as "" } from "./foo"; +////import { type "" as second } from "./bar"; +////const testFirst: first = "foo"; +////const testSecond: second = "foo"; + +verify.noErrors(); +verify.baselineRename(test.ranges()); +verify.baselineGoToDefinition(...test.ranges()); +verify.baselineFindAllReferences(...test.ranges()); diff --git a/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_values.ts b/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_values.ts new file mode 100644 index 0000000000000..bab23a9430be1 --- /dev/null +++ b/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_values.ts @@ -0,0 +1,19 @@ +/// + +// @Filename: /foo.ts +////const foo = "foo"; +////export { foo as "[|__|]" }; +////import { "[|__|]" as bar } from "./foo"; +////if (bar !== "foo") throw bar; + +// @Filename: /bar.ts +////import { "[|__|]" as first } from "./foo"; +////export { "[|__|]" as "" } from "./foo"; +////import { "" as second } from "./bar"; +////if (first !== "foo") throw first; +////if (second !== "foo") throw second; + +verify.noErrors(); +verify.baselineRename(test.ranges()); +verify.baselineGoToDefinition(...test.ranges()); +verify.baselineFindAllReferences(...test.ranges()); diff --git a/tests/cases/fourslash/refactorConvertImport_namedToNamespaceStringLiteral.ts b/tests/cases/fourslash/refactorConvertImport_namedToNamespaceStringLiteral.ts new file mode 100644 index 0000000000000..3cca0fe315be2 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertImport_namedToNamespaceStringLiteral.ts @@ -0,0 +1,17 @@ +/// + +/////*a*/import { "__" as Value, "__" as Type } from "foo";/*b*/ +////export { Value, Type }; // Need a named import for this +////const foo: Type = Value; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert import", + actionName: "Convert named imports to namespace import", + actionDescription: "Convert named imports to namespace import", + newContent: +`import * as foo_1 from "foo"; +import { "__" as Value, "__" as Type } from "foo"; +export { Value, Type }; // Need a named import for this +const foo: foo_1["__"] = foo_1["__"];`, +}); From 40a6d2af08fed2a14aa0c9f3822eefcf13ee8ea7 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Fri, 24 May 2024 00:16:25 -0400 Subject: [PATCH 02/11] run `hereby lint` and remove unused imports --- src/compiler/checker.ts | 1 - src/compiler/factory/utilities.ts | 1 - src/compiler/transformers/module/module.ts | 1 - 3 files changed, 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5414f798122b6..931370f232386 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -870,7 +870,6 @@ import { ModuleSpecifierResolutionHost, Mutable, NamedDeclaration, - NamedExportBindings, NamedExports, NamedImportsOrExports, NamedTupleMember, diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index e7031781b728d..a48270b6d47f5 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -131,7 +131,6 @@ import { MinusToken, Modifier, ModifiersArray, - moduleExportNameTextUnescaped, ModuleKind, ModuleName, MultiplicativeOperator, diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 1944f9e15a288..5126ff6cda886 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -123,7 +123,6 @@ import { ModifierFlags, ModuleExportName, moduleExportNameIsDefault, - moduleExportNameTextUnescaped, ModuleKind, NamespaceImport, Node, From 09ebadb7e9fd9b7dae2c3497e27e363cb5471abb Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Sun, 26 May 2024 16:51:09 -0400 Subject: [PATCH 03/11] string completions in `import {}` and `export {}` --- src/services/stringCompletions.ts | 21 ++++++++ ...tringCompletionsImportOrExportSpecifier.ts | 52 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 06f488ed47bcb..382a4334c8663 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -77,7 +77,9 @@ import { hasProperty, hasTrailingDirectorySeparator, hostGetCanonicalFileName, + ImportOrExportSpecifier, IndexedAccessTypeNode, + InternalSymbolName, isApplicableVersionedTypesKey, isArray, isCallExpression, @@ -104,6 +106,7 @@ import { LiteralTypeNode, mapDefined, MapLike, + moduleExportNameTextEscaped, moduleResolutionUsesNodeModules, ModuleSpecifierEnding, moduleSpecifiers, @@ -434,6 +437,24 @@ function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringL } const literals = contextualTypes.types.filter(literal => !tracker.hasValue(literal.value)); return { kind: StringLiteralCompletionKind.Types, types: literals, isNewIdentifier: false }; + + case SyntaxKind.ImportSpecifier: + case SyntaxKind.ExportSpecifier: + // Complete string aliases in `import { "|" } from` and `export { "|" } from` + const specifier = parent as ImportOrExportSpecifier; + if (specifier.propertyName && node !== specifier.propertyName) { + return; // Don't complete in `export { "..." as "|" } from` + } + const namedImportsOrExports = specifier.parent; + const { moduleSpecifier } = namedImportsOrExports.kind === SyntaxKind.NamedImports ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent; + if (!moduleSpecifier) return; + const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 + if (!moduleSpecifierSymbol) return; + const exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + const existing = new Set(namedImportsOrExports.elements.map(n => moduleExportNameTextEscaped(n.propertyName || n.name))); + const uniques = exports.filter(e => e.escapedName !== InternalSymbolName.Default && !existing.has(e.escapedName)); + return { kind: StringLiteralCompletionKind.Properties, symbols: uniques, hasIndexSignature: false }; + default: return fromContextualType() || fromContextualType(ContextFlags.None); } diff --git a/tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts b/tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts new file mode 100644 index 0000000000000..2f1c2d5962276 --- /dev/null +++ b/tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts @@ -0,0 +1,52 @@ +/// + +// @Filename: exports.ts +//// export let foo = 1; +//// let someValue = 2; +//// let someType = 3; +//// export { +//// someValue as "__some value", +//// someType as "__some type", +//// }; + +// @Filename: values.ts +//// import { type "/*valueImport0*/" } from "./exports"; +//// import { type "/*valueImport1*/" as valueImport1 } from "./exports"; +//// import { type "foo" as "/*valueImport2*/" } from "./exports"; +//// import { type foo, type "/*valueImport3*/" as valueImport3 } from "./exports"; +//// +//// export { type "/*valueExport0*/" } from "./exports"; +//// export { type "/*valueExport1*/" as valueExport1 } from "./exports"; +//// export { type "foo" as "/*valueExport2*/" } from "./exports"; +//// export { type foo, type "/*valueExport3*/" } from "./exports"; + +// @Filename: types.ts +//// import { "/*typeImport0*/" } from "./exports"; +//// import { "/*typeImport1*/" as typeImport1 } from "./exports"; +//// import { "foo" as "/*typeImport2*/" } from "./exports"; +//// import { foo, "/*typeImport3*/" as typeImport3 } from "./exports"; +//// +//// export { type "/*typeExport0*/" } from "./exports"; +//// export { type "/*typeExport1*/" as typeExport1 } from "./exports"; +//// export { type "foo" as "/*typeExport2*/" } from "./exports"; +//// export { type foo, type "/*typeExport3*/" } from "./exports"; + +verify.completions({ marker: "valueImport0", exact: ["__some type", "__some value", "foo"] }); +verify.completions({ marker: "valueImport1", exact: ["__some type", "__some value", "foo"] }); +verify.completions({ marker: "valueImport2", exact: [] }); +verify.completions({ marker: "valueImport3", exact: ["__some type", "__some value"] }); + +verify.completions({ marker: "valueExport0", exact: ["__some type", "__some value", "foo"] }); +verify.completions({ marker: "valueExport1", exact: ["__some type", "__some value", "foo"] }); +verify.completions({ marker: "valueExport2", exact: [] }); +verify.completions({ marker: "valueExport3", exact: ["__some type", "__some value"] }); + +verify.completions({ marker: "typeImport0", exact: ["__some type", "__some value", "foo"] }); +verify.completions({ marker: "typeImport1", exact: ["__some type", "__some value", "foo"] }); +verify.completions({ marker: "typeImport2", exact: [] }); +verify.completions({ marker: "typeImport3", exact: ["__some type", "__some value"] }); + +verify.completions({ marker: "typeExport0", exact: ["__some type", "__some value", "foo"] }); +verify.completions({ marker: "typeExport1", exact: ["__some type", "__some value", "foo"] }); +verify.completions({ marker: "typeExport2", exact: [] }); +verify.completions({ marker: "typeExport3", exact: ["__some type", "__some value"] }); From 99d930c8b22c770721e945f3d5814fd99e54d463 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Sun, 26 May 2024 23:31:30 -0400 Subject: [PATCH 04/11] fix type vs. value in tests --- ...tringCompletionsImportOrExportSpecifier.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts b/tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts index 2f1c2d5962276..ead04bb57a5a6 100644 --- a/tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts +++ b/tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts @@ -10,25 +10,25 @@ //// }; // @Filename: values.ts -//// import { type "/*valueImport0*/" } from "./exports"; -//// import { type "/*valueImport1*/" as valueImport1 } from "./exports"; -//// import { type "foo" as "/*valueImport2*/" } from "./exports"; -//// import { type foo, type "/*valueImport3*/" as valueImport3 } from "./exports"; +//// import { "/*valueImport0*/" } from "./exports"; +//// import { "/*valueImport1*/" as valueImport1 } from "./exports"; +//// import { foo as "/*valueImport2*/" } from "./exports"; +//// import { foo, "/*valueImport3*/" as valueImport3 } from "./exports"; //// -//// export { type "/*valueExport0*/" } from "./exports"; -//// export { type "/*valueExport1*/" as valueExport1 } from "./exports"; -//// export { type "foo" as "/*valueExport2*/" } from "./exports"; -//// export { type foo, type "/*valueExport3*/" } from "./exports"; +//// export { "/*valueExport0*/" } from "./exports"; +//// export { "/*valueExport1*/" as valueExport1 } from "./exports"; +//// export { foo as "/*valueExport2*/" } from "./exports"; +//// export { foo, "/*valueExport3*/" } from "./exports"; // @Filename: types.ts -//// import { "/*typeImport0*/" } from "./exports"; -//// import { "/*typeImport1*/" as typeImport1 } from "./exports"; -//// import { "foo" as "/*typeImport2*/" } from "./exports"; -//// import { foo, "/*typeImport3*/" as typeImport3 } from "./exports"; +//// import { type "/*typeImport0*/" } from "./exports"; +//// import { type "/*typeImport1*/" as typeImport1 } from "./exports"; +//// import { type foo as "/*typeImport2*/" } from "./exports"; +//// import { type foo, type "/*typeImport3*/" as typeImport3 } from "./exports"; //// //// export { type "/*typeExport0*/" } from "./exports"; //// export { type "/*typeExport1*/" as typeExport1 } from "./exports"; -//// export { type "foo" as "/*typeExport2*/" } from "./exports"; +//// export { type foo as "/*typeExport2*/" } from "./exports"; //// export { type foo, type "/*typeExport3*/" } from "./exports"; verify.completions({ marker: "valueImport0", exact: ["__some type", "__some value", "foo"] }); From 1e145fac1afa57c025c27ddf8a358f8bbf7e1256 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Sun, 26 May 2024 23:54:38 -0400 Subject: [PATCH 05/11] completions in `import {}` and `export {}` --- src/compiler/scanner.ts | 24 ++++++++ src/services/completions.ts | 22 +++++-- .../completionsImportOrExportSpecifier.ts | 58 +++++++++++++++++++ 3 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/completionsImportOrExportSpecifier.ts diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 5d93e57ebe660..3578aae3b8888 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -997,6 +997,30 @@ export function isIdentifierText(name: string, languageVersion: ScriptTarget | u return true; } +/** @internal */ +export function generateIdentifierForArbitraryString(text: string, languageVersion: ScriptTarget | undefined): string { + let needsUnderscore = false; + let identifier = ""; + let ch: number; + + // Convert "(example, text)" into "_example_text_" + for (let i = 0; i < text.length; i += charSize(ch)) { + ch = codePointAt(text, i); + if (i === 0 ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion)) { + if (needsUnderscore) identifier += "_"; + identifier += String.fromCodePoint(ch); + needsUnderscore = false; + } + else { + needsUnderscore = true; + } + } + if (needsUnderscore) identifier += "_"; + + // Default to "_" if the provided text was empty + return identifier || "_"; +} + const enum ClassSetExpressionType { Unknown, ClassUnion, diff --git a/src/services/completions.ts b/src/services/completions.ts index 7dcb68f22165b..8437c72ae8878 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -75,6 +75,7 @@ import { formatting, FunctionLikeDeclaration, FutureSymbolExportInfo, + generateIdentifierForArbitraryString, getAllSuperTypeNodes, getAncestor, getCombinedLocalAndExportSymbolFlags, @@ -1837,10 +1838,19 @@ function createCompletionEntry( } const parentNamedImportOrExport = findAncestor(location, isNamedImportsOrExports); - if (parentNamedImportOrExport?.kind === SyntaxKind.NamedImports) { - const possibleToken = stringToToken(name); - if (parentNamedImportOrExport && possibleToken && (possibleToken === SyntaxKind.AwaitKeyword || isNonContextualKeyword(possibleToken))) { - insertText = `${name} as ${name}_`; + if (parentNamedImportOrExport) { + const languageVersion = getEmitScriptTarget(host.getCompilationSettings()); + if (!isIdentifierText(name, languageVersion)) { + insertText = JSON.stringify(name); + if (parentNamedImportOrExport.kind === SyntaxKind.NamedImports) { + insertText += " as " + generateIdentifierForArbitraryString(name, languageVersion); + } + } + else if (parentNamedImportOrExport.kind === SyntaxKind.NamedImports) { + const possibleToken = stringToToken(name); + if (possibleToken && (possibleToken === SyntaxKind.AwaitKeyword || isNonContextualKeyword(possibleToken))) { + insertText = `${name} as ${name}_`; + } } } @@ -5251,6 +5261,10 @@ function getCompletionEntryDisplayNameForSymbol( if (isIdentifierText(name, target, jsxIdentifierExpected ? LanguageVariant.JSX : LanguageVariant.Standard) || symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } + if (symbol.flags & SymbolFlags.Alias) { + // Allow non-identifier import/export aliases since we can insert them as string literals + return { name, needsConvertPropertyAccess: true }; + } switch (kind) { case CompletionKind.MemberLike: return originIsComputedPropertyName(origin) ? { name: origin.symbolName, needsConvertPropertyAccess: false } : undefined; diff --git a/tests/cases/fourslash/completionsImportOrExportSpecifier.ts b/tests/cases/fourslash/completionsImportOrExportSpecifier.ts new file mode 100644 index 0000000000000..533c6f315d031 --- /dev/null +++ b/tests/cases/fourslash/completionsImportOrExportSpecifier.ts @@ -0,0 +1,58 @@ +/// + +// @Filename: exports.ts +//// export let foo = 1; +//// let someValue = 2; +//// let someType = 3; +//// export { +//// someValue as "__some value", +//// someType as "__some type", +//// }; + +// @Filename: values.ts +//// import { /*valueImport0*/ } from "./exports"; +//// import { /*valueImport1*/ as valueImport1 } from "./exports"; +//// import { foo as /*valueImport2*/ } from "./exports"; +//// import { foo, /*valueImport3*/ as valueImport3 } from "./exports"; +//// +//// export { /*valueExport0*/ } from "./exports"; +//// export { /*valueExport1*/ as valueExport1 } from "./exports"; +//// export { foo as /*valueExport2*/ } from "./exports"; +//// export { foo, /*valueExport3*/ } from "./exports"; + +// @Filename: types.ts +//// import { type /*typeImport0*/ } from "./exports"; +//// import { type /*typeImport1*/ as typeImport1 } from "./exports"; +//// import { type foo as /*typeImport2*/ } from "./exports"; +//// import { type foo, type /*typeImport3*/ as typeImport3 } from "./exports"; +//// +//// export { type /*typeExport0*/ } from "./exports"; +//// export { type /*typeExport1*/ as typeExport1 } from "./exports"; +//// export { type foo as /*typeExport2*/ } from "./exports"; +//// export { type foo, type /*typeExport3*/ } from "./exports"; + +const __some_type = { name: "__some type", insertText: '"__some type"' } +const __some_value = { name: "__some value", insertText: '"__some value"' } +const __some_type_as = { name: "__some type", insertText: '"__some type" as __some_type' } +const __some_value_as = { name: "__some value", insertText: '"__some value" as __some_value' } +const typeKeyword = { name: "type", sortText: completion.SortText.GlobalsOrKeywords } + +verify.completions({ marker: "valueImport0", exact: [__some_type_as, __some_value_as, "foo", typeKeyword] }); +verify.completions({ marker: "valueImport1", exact: [__some_type_as, __some_value_as, "foo", typeKeyword] }); +verify.completions({ marker: "valueImport2", exact: [] }); +verify.completions({ marker: "valueImport3", exact: [__some_type_as, __some_value_as, typeKeyword] }); + +verify.completions({ marker: "valueExport0", exact: [__some_type, __some_value, "foo", typeKeyword] }); +verify.completions({ marker: "valueExport1", exact: [__some_type, __some_value, "foo", typeKeyword] }); +verify.completions({ marker: "valueExport2", exact: [] }); +verify.completions({ marker: "valueExport3", exact: [__some_type, __some_value, typeKeyword] }); + +verify.completions({ marker: "typeImport0", exact: [__some_type_as, __some_value_as, "foo"] }); +verify.completions({ marker: "typeImport1", exact: [__some_type_as, __some_value_as, "foo"] }); +verify.completions({ marker: "typeImport2", exact: [] }); +verify.completions({ marker: "typeImport3", exact: [__some_type_as, __some_value_as] }); + +verify.completions({ marker: "typeExport0", exact: [] }); +verify.completions({ marker: "typeExport1", exact: [__some_type, __some_value, "foo"] }); +verify.completions({ marker: "typeExport2", exact: [] }); +verify.completions({ marker: "typeExport3", exact: [] }); From 075e93d2f8ea6a8875149082db9d2645f7a77364 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 29 May 2024 20:42:35 -0400 Subject: [PATCH 06/11] use comma-separated variations for `module` tests --- ...leNamespaceIdentifiers_commonjs.errors.txt | 42 ----- ...oduleNamespaceIdentifiers_commonjs.symbols | 82 ---------- ...yModuleNamespaceIdentifiers_commonjs.types | 151 ------------------ ...Identifiers_module(module=amd).errors.txt} | 28 ++-- ...amespaceIdentifiers_module(module=amd).js} | 52 +++--- ...aceIdentifiers_module(module=amd).symbols} | 90 +++++------ ...spaceIdentifiers_module(module=amd).types} | 24 +-- ...ifiers_module(module=commonjs).errors.txt} | 28 ++-- ...aceIdentifiers_module(module=commonjs).js} | 58 +++---- ...entifiers_module(module=commonjs).symbols} | 90 +++++------ ...Identifiers_module(module=commonjs).types} | 24 +-- ...ntifiers_module(module=es2020).errors.txt} | 56 +++---- ...spaceIdentifiers_module(module=es2020).js} | 46 +++--- ...Identifiers_module(module=es2020).symbols} | 90 +++++------ ...ceIdentifiers_module(module=es2020).types} | 24 +-- ...ntifiers_module(module=es2022).errors.txt} | 28 ++-- ...espaceIdentifiers_module(module=es2022).js | 67 ++++++++ ...Identifiers_module(module=es2022).symbols} | 90 +++++------ ...ceIdentifiers_module(module=es2022).types} | 24 +-- ...eIdentifiers_module(module=es6).errors.txt | 84 ++++++++++ ...amespaceIdentifiers_module(module=es6).js} | 46 +++--- ...paceIdentifiers_module(module=es6).symbols | 82 ++++++++++ ...espaceIdentifiers_module(module=es6).types | 151 ++++++++++++++++++ ...ntifiers_module(module=esnext).errors.txt} | 28 ++-- ...espaceIdentifiers_module(module=esnext).js | 67 ++++++++ ...eIdentifiers_module(module=esnext).symbols | 82 ++++++++++ ...aceIdentifiers_module(module=esnext).types | 151 ++++++++++++++++++ ...entifiers_module(module=node16).errors.txt | 42 +++++ ...espaceIdentifiers_module(module=node16).js | 94 +++++++++++ ...eIdentifiers_module(module=node16).symbols | 82 ++++++++++ ...aceIdentifiers_module(module=node16).types | 151 ++++++++++++++++++ ...tifiers_module(module=nodenext).errors.txt | 42 +++++ ...paceIdentifiers_module(module=nodenext).js | 94 +++++++++++ ...dentifiers_module(module=nodenext).symbols | 82 ++++++++++ ...eIdentifiers_module(module=nodenext).types | 151 ++++++++++++++++++ ...Identifiers_module(module=none).errors.txt | 42 +++++ ...amespaceIdentifiers_module(module=none).js | 71 ++++++++ ...aceIdentifiers_module(module=none).symbols | 82 ++++++++++ ...spaceIdentifiers_module(module=none).types | 151 ++++++++++++++++++ ...tifiers_module(module=preserve).errors.txt | 42 +++++ ...paceIdentifiers_module(module=preserve).js | 67 ++++++++ ...dentifiers_module(module=preserve).symbols | 82 ++++++++++ ...eIdentifiers_module(module=preserve).types | 151 ++++++++++++++++++ ...entifiers_module(module=system).errors.txt | 42 +++++ ...spaceIdentifiers_module(module=system).js} | 62 +++---- ...eIdentifiers_module(module=system).symbols | 82 ++++++++++ ...aceIdentifiers_module(module=system).types | 151 ++++++++++++++++++ ...eIdentifiers_module(module=umd).errors.txt | 42 +++++ ...amespaceIdentifiers_module(module=umd).js} | 60 +++---- ...paceIdentifiers_module(module=umd).symbols | 82 ++++++++++ ...espaceIdentifiers_module(module=umd).types | 151 ++++++++++++++++++ ...raryModuleNamespaceIdentifiers_umd.symbols | 82 ---------- ...itraryModuleNamespaceIdentifiers_umd.types | 151 ------------------ ...arbitraryModuleNamespaceIdentifiers_amd.ts | 33 ---- ...raryModuleNamespaceIdentifiers_commonjs.ts | 33 ---- ...itraryModuleNamespaceIdentifiers_es2015.ts | 33 ---- ...itraryModuleNamespaceIdentifiers_es2022.ts | 33 ---- ...traryModuleNamespaceIdentifiers_module.ts} | 22 +-- ...itraryModuleNamespaceIdentifiers_system.ts | 33 ---- 59 files changed, 3145 insertions(+), 1158 deletions(-) delete mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.errors.txt delete mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.symbols delete mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.types rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_system.errors.txt => arbitraryModuleNamespaceIdentifiers_module(module=amd).errors.txt} (79%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_amd.js => arbitraryModuleNamespaceIdentifiers_module(module=amd).js} (58%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_es2015.symbols => arbitraryModuleNamespaceIdentifiers_module(module=amd).symbols} (73%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_es2015.types => arbitraryModuleNamespaceIdentifiers_module(module=amd).types} (89%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_es2022.errors.txt => arbitraryModuleNamespaceIdentifiers_module(module=commonjs).errors.txt} (79%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_commonjs.js => arbitraryModuleNamespaceIdentifiers_module(module=commonjs).js} (58%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_es2022.symbols => arbitraryModuleNamespaceIdentifiers_module(module=commonjs).symbols} (73%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_system.types => arbitraryModuleNamespaceIdentifiers_module(module=commonjs).types} (89%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_es2015.errors.txt => arbitraryModuleNamespaceIdentifiers_module(module=es2020).errors.txt} (80%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_es2022.js => arbitraryModuleNamespaceIdentifiers_module(module=es2020).js} (77%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_amd.symbols => arbitraryModuleNamespaceIdentifiers_module(module=es2020).symbols} (73%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_es2022.types => arbitraryModuleNamespaceIdentifiers_module(module=es2020).types} (89%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_amd.errors.txt => arbitraryModuleNamespaceIdentifiers_module(module=es2022).errors.txt} (69%) create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).js rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_system.symbols => arbitraryModuleNamespaceIdentifiers_module(module=es2022).symbols} (73%) rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_amd.types => arbitraryModuleNamespaceIdentifiers_module(module=es2022).types} (89%) create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).errors.txt rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_es2015.js => arbitraryModuleNamespaceIdentifiers_module(module=es6).js} (77%) create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).types rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_umd.errors.txt => arbitraryModuleNamespaceIdentifiers_module(module=esnext).errors.txt} (69%) create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).errors.txt create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).js create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).errors.txt rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_system.js => arbitraryModuleNamespaceIdentifiers_module(module=system).js} (59%) create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).types create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).errors.txt rename tests/baselines/reference/{arbitraryModuleNamespaceIdentifiers_umd.js => arbitraryModuleNamespaceIdentifiers_module(module=umd).js} (59%) create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).symbols create mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).types delete mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.symbols delete mode 100644 tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.types delete mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts delete mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts delete mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts delete mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts rename tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/{arbitraryModuleNamespaceIdentifiers_umd.ts => arbitraryModuleNamespaceIdentifiers_module.ts} (84%) delete mode 100644 tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.errors.txt deleted file mode 100644 index 288d72e0401c9..0000000000000 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.errors.txt +++ /dev/null @@ -1,42 +0,0 @@ -arbitraryModuleNamespaceIdentifiers_commonjs.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_commonjs.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_commonjs.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. - - -==== arbitraryModuleNamespaceIdentifiers_commonjs.ts (3 errors) ==== - const someValue = "someValue"; - type someType = "someType"; - - export { someValue as "" }; - import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - if (valueX !== "someValue") throw "should be someValue"; - - export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - if (valueY !== "someValue") throw "should be someValue"; - - export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - if (valueZ[""] !== "someValue") throw "should be someValue"; - if (valueZ[""] !== "someValue") throw "should be someValue"; - if (valueZ[""] !== valueZ) throw "should be export namespace"; - - export { type someType as "" }; - import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - const importTest: typeA = "expect error about someType"; - ~~~~~~~~~~ -!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - - export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - const reimportTest: typeB = "expect error about someType"; - ~~~~~~~~~~~~ -!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - - export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; - export type otherType = "otherType"; - const importStarTestA: typeC.otherType = "expect error about otherType"; - ~~~~~~~~~~~~~~~ -!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. - \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.symbols deleted file mode 100644 index 607e141116e71..0000000000000 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.symbols +++ /dev/null @@ -1,82 +0,0 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts] //// - -=== arbitraryModuleNamespaceIdentifiers_commonjs.ts === -const someValue = "someValue"; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 0, 5)) - -type someType = "someType"; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 0, 30)) - -export { someValue as "" }; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 0, 5)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 3, 8)) - -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 4, 8)) - -if (valueX !== "someValue") throw "should be someValue"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 4, 8)) - -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 7, 8)) - -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 8, 8)) - -if (valueY !== "someValue") throw "should be someValue"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 8, 8)) - -export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 11, 6)) - -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) - -if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 3, 8)) - -if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 7, 8)) - -if (valueZ[""] !== valueZ) throw "should be export namespace"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 11, 6)) ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 12, 8)) - -export { type someType as "" }; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 0, 30)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 17, 8)) - -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 18, 8)) - -const importTest: typeA = "expect error about someType"; ->importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 19, 5)) ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 18, 8)) - -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 21, 8)) - -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 22, 8)) - -const reimportTest: typeB = "expect error about someType"; ->reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 23, 5)) ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 22, 8)) - -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 25, 11)) - -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 26, 8)) - -export type otherType = "otherType"; ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 26, 85)) - -const importStarTestA: typeC.otherType = "expect error about otherType"; ->importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 28, 5)) ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 26, 8)) ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_commonjs.ts, 26, 85)) - diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.types deleted file mode 100644 index 9ff092140a8f0..0000000000000 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.types +++ /dev/null @@ -1,151 +0,0 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts] //// - -=== arbitraryModuleNamespaceIdentifiers_commonjs.ts === -const someValue = "someValue"; ->someValue : "someValue" -> : ^^^^^^^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ - -type someType = "someType"; ->someType : "someType" -> : ^^^^^^^^^^ - -export { someValue as "" }; ->someValue : "someValue" -> : ^^^^^^^^^^^ ->"" : "someValue" -> : ^^^^^^^^^^^ - -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->valueX : "someValue" -> : ^^^^^^^^^^^ - -if (valueX !== "someValue") throw "should be someValue"; ->valueX !== "someValue" : boolean -> : ^^^^^^^ ->valueX : "someValue" -> : ^^^^^^^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ ->"should be someValue" : "should be someValue" -> : ^^^^^^^^^^^^^^^^^^^^^ - -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->"" : "someValue" -> : ^^^^^^^^^^^ - -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->valueY : "someValue" -> : ^^^^^^^^^^^ - -if (valueY !== "someValue") throw "should be someValue"; ->valueY !== "someValue" : boolean -> : ^^^^^^^ ->valueY : "someValue" -> : ^^^^^^^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ ->"should be someValue" : "should be someValue" -> : ^^^^^^^^^^^^^^^^^^^^^ - -export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->"" : typeof valueZ -> : ^^^^^^^^^^^^^ - -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ - -if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ[""] !== "someValue" : boolean -> : ^^^^^^^ ->valueZ[""] : "someValue" -> : ^^^^^^^^^^^ ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ ->"" : "" -> : ^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ ->"should be someValue" : "should be someValue" -> : ^^^^^^^^^^^^^^^^^^^^^ - -if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ[""] !== "someValue" : boolean -> : ^^^^^^^ ->valueZ[""] : "someValue" -> : ^^^^^^^^^^^ ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ ->"" : "" -> : ^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ ->"should be someValue" : "should be someValue" -> : ^^^^^^^^^^^^^^^^^^^^^ - -if (valueZ[""] !== valueZ) throw "should be export namespace"; ->valueZ[""] !== valueZ : boolean -> : ^^^^^^^ ->valueZ[""] : typeof valueZ -> : ^^^^^^^^^^^^^ ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ ->"" : "" -> : ^^^^^ ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ ->"should be export namespace" : "should be export namespace" -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -export { type someType as "" }; ->someType : any -> : ^^^ ->"" : any -> : ^^^ - -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->typeA : any -> : ^^^ - -const importTest: typeA = "expect error about someType"; ->importTest : "someType" -> : ^^^^^^^^^^ ->"expect error about someType" : "expect error about someType" -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->"" : any -> : ^^^ - -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->typeB : any -> : ^^^ - -const reimportTest: typeB = "expect error about someType"; ->reimportTest : "someType" -> : ^^^^^^^^^^ ->"expect error about someType" : "expect error about someType" -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->"" : typeof valueZ -> : ^^^^^^^^^^^^^ - -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; ->typeC : typeof valueZ -> : ^^^^^^^^^^^^^ - -export type otherType = "otherType"; ->otherType : "otherType" -> : ^^^^^^^^^^^ - -const importStarTestA: typeC.otherType = "expect error about otherType"; ->importStarTestA : "otherType" -> : ^^^^^^^^^^^ ->typeC : any -> : ^^^ ->"expect error about otherType" : "expect error about otherType" -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).errors.txt similarity index 79% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.errors.txt rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).errors.txt index 3540ebbaa5eda..cc359bceb4904 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.errors.txt +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).errors.txt @@ -1,40 +1,40 @@ -arbitraryModuleNamespaceIdentifiers_system.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_system.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_system.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. -==== arbitraryModuleNamespaceIdentifiers_system.ts (3 errors) ==== +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; - import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; - export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; - import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; - export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; - import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; - import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; ~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; - import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; ~~~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; - import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).js similarity index 58% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.js rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).js index 297bf6c85ffdb..1a72c31df4c08 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.js +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).js @@ -1,55 +1,55 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -//// [arbitraryModuleNamespaceIdentifiers_amd.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.ts] const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; -//// [arbitraryModuleNamespaceIdentifiers_amd.js] -define(["require", "exports", "./arbitraryModuleNamespaceIdentifiers_amd", "./arbitraryModuleNamespaceIdentifiers_amd", "./arbitraryModuleNamespaceIdentifiers_amd", "./arbitraryModuleNamespaceIdentifiers_amd", "./arbitraryModuleNamespaceIdentifiers_amd"], function (require, exports, arbitraryModuleNamespaceIdentifiers_amd_1, arbitraryModuleNamespaceIdentifiers_amd_2, arbitraryModuleNamespaceIdentifiers_amd_3, arbitraryModuleNamespaceIdentifiers_amd_4, arbitraryModuleNamespaceIdentifiers_amd_5) { +//// [arbitraryModuleNamespaceIdentifiers_module.js] +define(["require", "exports", "./arbitraryModuleNamespaceIdentifiers_module", "./arbitraryModuleNamespaceIdentifiers_module", "./arbitraryModuleNamespaceIdentifiers_module", "./arbitraryModuleNamespaceIdentifiers_module", "./arbitraryModuleNamespaceIdentifiers_module"], function (require, exports, arbitraryModuleNamespaceIdentifiers_module_1, arbitraryModuleNamespaceIdentifiers_module_2, arbitraryModuleNamespaceIdentifiers_module_3, arbitraryModuleNamespaceIdentifiers_module_4, arbitraryModuleNamespaceIdentifiers_module_5) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports[""] = exports[""] = exports[""] = void 0; const someValue = "someValue"; exports[""] = someValue; - if (arbitraryModuleNamespaceIdentifiers_amd_1[""] !== "someValue") + if (arbitraryModuleNamespaceIdentifiers_module_1[""] !== "someValue") throw "should be someValue"; - Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_amd_2[""]; } }); - if (arbitraryModuleNamespaceIdentifiers_amd_3[""] !== "someValue") + Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_module_2[""]; } }); + if (arbitraryModuleNamespaceIdentifiers_module_3[""] !== "someValue") throw "should be someValue"; - exports[""] = arbitraryModuleNamespaceIdentifiers_amd_4; - if (arbitraryModuleNamespaceIdentifiers_amd_5[""][""] !== "someValue") + exports[""] = arbitraryModuleNamespaceIdentifiers_module_4; + if (arbitraryModuleNamespaceIdentifiers_module_5[""][""] !== "someValue") throw "should be someValue"; - if (arbitraryModuleNamespaceIdentifiers_amd_5[""][""] !== "someValue") + if (arbitraryModuleNamespaceIdentifiers_module_5[""][""] !== "someValue") throw "should be someValue"; - if (arbitraryModuleNamespaceIdentifiers_amd_5[""][""] !== arbitraryModuleNamespaceIdentifiers_amd_5[""]) + if (arbitraryModuleNamespaceIdentifiers_module_5[""][""] !== arbitraryModuleNamespaceIdentifiers_module_5[""]) throw "should be export namespace"; const importTest = "expect error about someType"; const reimportTest = "expect error about someType"; @@ -57,13 +57,13 @@ define(["require", "exports", "./arbitraryModuleNamespaceIdentifiers_amd", "./ar }); -//// [arbitraryModuleNamespaceIdentifiers_amd.d.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] declare const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export { type someType as "" }; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).symbols similarity index 73% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.symbols rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).symbols index 52536fcde4470..a792b7d3f5280 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.symbols +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).symbols @@ -1,82 +1,82 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -=== arbitraryModuleNamespaceIdentifiers_es2015.ts === +=== arbitraryModuleNamespaceIdentifiers_module.ts === const someValue = "someValue"; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 0, 5)) +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) type someType = "someType"; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 0, 30)) +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) export { someValue as "" }; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 0, 5)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 3, 8)) +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 4, 8)) +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) if (valueX !== "someValue") throw "should be someValue"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 4, 8)) +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 7, 8)) +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 8, 8)) +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) if (valueY !== "someValue") throw "should be someValue"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 8, 8)) +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 11, 6)) +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 3, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 7, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) if (valueZ[""] !== valueZ) throw "should be export namespace"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 11, 6)) ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 12, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) export { type someType as "" }; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 0, 30)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 17, 8)) +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 18, 8)) +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) const importTest: typeA = "expect error about someType"; ->importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 19, 5)) ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 18, 8)) +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 21, 8)) +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 22, 8)) +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) const reimportTest: typeB = "expect error about someType"; ->reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 23, 5)) ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 22, 8)) +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 25, 11)) +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 26, 8)) +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) export type otherType = "otherType"; ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 26, 83)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) const importStarTestA: typeC.otherType = "expect error about otherType"; ->importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 28, 5)) ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 26, 8)) ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_es2015.ts, 26, 83)) +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).types similarity index 89% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.types rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).types index 5af23a0c08be8..4574f9754d0b4 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.types +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=amd).types @@ -1,6 +1,6 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -=== arbitraryModuleNamespaceIdentifiers_es2015.ts === +=== arbitraryModuleNamespaceIdentifiers_module.ts === const someValue = "someValue"; >someValue : "someValue" > : ^^^^^^^^^^^ @@ -17,7 +17,7 @@ export { someValue as "" }; >"" : "someValue" > : ^^^^^^^^^^^ -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueX : "someValue" > : ^^^^^^^^^^^ @@ -31,11 +31,11 @@ if (valueX !== "someValue") throw "should be someValue"; >"should be someValue" : "should be someValue" > : ^^^^^^^^^^^^^^^^^^^^^ -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : "someValue" > : ^^^^^^^^^^^ -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueY : "someValue" > : ^^^^^^^^^^^ @@ -49,11 +49,11 @@ if (valueY !== "someValue") throw "should be someValue"; >"should be someValue" : "should be someValue" > : ^^^^^^^^^^^^^^^^^^^^^ -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : typeof valueZ > : ^^^^^^^^^^^^^ -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueZ : typeof valueZ > : ^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ export { type someType as "" }; >"" : any > : ^^^ -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeA : any > : ^^^ @@ -115,11 +115,11 @@ const importTest: typeA = "expect error about someType"; >"expect error about someType" : "expect error about someType" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : any > : ^^^ -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeB : any > : ^^^ @@ -129,11 +129,11 @@ const reimportTest: typeB = "expect error about someType"; >"expect error about someType" : "expect error about someType" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : typeof valueZ > : ^^^^^^^^^^^^^ -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeC : typeof valueZ > : ^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).errors.txt similarity index 79% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.errors.txt rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).errors.txt index 2c0d15244f034..cc359bceb4904 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.errors.txt +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).errors.txt @@ -1,40 +1,40 @@ -arbitraryModuleNamespaceIdentifiers_es2022.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_es2022.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_es2022.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. -==== arbitraryModuleNamespaceIdentifiers_es2022.ts (3 errors) ==== +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; - import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; - export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; - import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; - export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; - import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; - import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; ~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; - import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; ~~~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; - import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).js similarity index 58% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.js rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).js index f6ddaa96a78e5..43f95451590dc 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_commonjs.js +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).js @@ -1,71 +1,71 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -//// [arbitraryModuleNamespaceIdentifiers_commonjs.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.ts] const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; -//// [arbitraryModuleNamespaceIdentifiers_commonjs.js] +//// [arbitraryModuleNamespaceIdentifiers_module.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports[""] = exports[""] = exports[""] = void 0; const someValue = "someValue"; exports[""] = someValue; -const arbitraryModuleNamespaceIdentifiers_commonjs_1 = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); -if (arbitraryModuleNamespaceIdentifiers_commonjs_1[""] !== "someValue") +const arbitraryModuleNamespaceIdentifiers_module_1 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_1[""] !== "someValue") throw "should be someValue"; -var arbitraryModuleNamespaceIdentifiers_commonjs_2 = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); -Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_commonjs_2[""]; } }); -const arbitraryModuleNamespaceIdentifiers_commonjs_3 = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); -if (arbitraryModuleNamespaceIdentifiers_commonjs_3[""] !== "someValue") +var arbitraryModuleNamespaceIdentifiers_module_2 = require("./arbitraryModuleNamespaceIdentifiers_module"); +Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_module_2[""]; } }); +const arbitraryModuleNamespaceIdentifiers_module_3 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_3[""] !== "someValue") throw "should be someValue"; -exports[""] = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); -const arbitraryModuleNamespaceIdentifiers_commonjs_4 = require("./arbitraryModuleNamespaceIdentifiers_commonjs"); -if (arbitraryModuleNamespaceIdentifiers_commonjs_4[""][""] !== "someValue") +exports[""] = require("./arbitraryModuleNamespaceIdentifiers_module"); +const arbitraryModuleNamespaceIdentifiers_module_4 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") throw "should be someValue"; -if (arbitraryModuleNamespaceIdentifiers_commonjs_4[""][""] !== "someValue") +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") throw "should be someValue"; -if (arbitraryModuleNamespaceIdentifiers_commonjs_4[""][""] !== arbitraryModuleNamespaceIdentifiers_commonjs_4[""]) +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== arbitraryModuleNamespaceIdentifiers_module_4[""]) throw "should be export namespace"; const importTest = "expect error about someType"; const reimportTest = "expect error about someType"; const importStarTestA = "expect error about otherType"; -//// [arbitraryModuleNamespaceIdentifiers_commonjs.d.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] declare const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export { type someType as "" }; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).symbols similarity index 73% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.symbols rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).symbols index 61516af73b8a3..a792b7d3f5280 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.symbols +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).symbols @@ -1,82 +1,82 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -=== arbitraryModuleNamespaceIdentifiers_es2022.ts === +=== arbitraryModuleNamespaceIdentifiers_module.ts === const someValue = "someValue"; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 0, 5)) +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) type someType = "someType"; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 0, 30)) +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) export { someValue as "" }; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 0, 5)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 3, 8)) +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 4, 8)) +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) if (valueX !== "someValue") throw "should be someValue"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 4, 8)) +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 7, 8)) +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 8, 8)) +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) if (valueY !== "someValue") throw "should be someValue"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 8, 8)) +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 11, 6)) +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 3, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 7, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) if (valueZ[""] !== valueZ) throw "should be export namespace"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 11, 6)) ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 12, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) export { type someType as "" }; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 0, 30)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 17, 8)) +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 18, 8)) +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) const importTest: typeA = "expect error about someType"; ->importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 19, 5)) ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 18, 8)) +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 21, 8)) +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 22, 8)) +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) const reimportTest: typeB = "expect error about someType"; ->reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 23, 5)) ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 22, 8)) +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 25, 11)) +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 26, 8)) +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) export type otherType = "otherType"; ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 26, 83)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) const importStarTestA: typeC.otherType = "expect error about otherType"; ->importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 28, 5)) ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 26, 8)) ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_es2022.ts, 26, 83)) +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).types similarity index 89% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.types rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).types index 1fca5f6fb7977..4574f9754d0b4 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.types +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=commonjs).types @@ -1,6 +1,6 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -=== arbitraryModuleNamespaceIdentifiers_system.ts === +=== arbitraryModuleNamespaceIdentifiers_module.ts === const someValue = "someValue"; >someValue : "someValue" > : ^^^^^^^^^^^ @@ -17,7 +17,7 @@ export { someValue as "" }; >"" : "someValue" > : ^^^^^^^^^^^ -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueX : "someValue" > : ^^^^^^^^^^^ @@ -31,11 +31,11 @@ if (valueX !== "someValue") throw "should be someValue"; >"should be someValue" : "should be someValue" > : ^^^^^^^^^^^^^^^^^^^^^ -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : "someValue" > : ^^^^^^^^^^^ -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueY : "someValue" > : ^^^^^^^^^^^ @@ -49,11 +49,11 @@ if (valueY !== "someValue") throw "should be someValue"; >"should be someValue" : "should be someValue" > : ^^^^^^^^^^^^^^^^^^^^^ -export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : typeof valueZ > : ^^^^^^^^^^^^^ -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueZ : typeof valueZ > : ^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ export { type someType as "" }; >"" : any > : ^^^ -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeA : any > : ^^^ @@ -115,11 +115,11 @@ const importTest: typeA = "expect error about someType"; >"expect error about someType" : "expect error about someType" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : any > : ^^^ -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeB : any > : ^^^ @@ -129,11 +129,11 @@ const reimportTest: typeB = "expect error about someType"; >"expect error about someType" : "expect error about someType" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : typeof valueZ > : ^^^^^^^^^^^^^ -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeC : typeof valueZ > : ^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).errors.txt similarity index 80% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.errors.txt rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).errors.txt index f2b9a27149cf3..01f0de2be6e68 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.errors.txt +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).errors.txt @@ -1,48 +1,48 @@ -arbitraryModuleNamespaceIdentifiers_es2015.ts(4,23): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(5,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(8,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(8,19): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(9,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(12,13): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(13,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(18,27): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(19,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(22,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(22,24): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(23,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(26,18): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(27,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_es2015.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(4,23): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(5,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(8,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(8,19): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(9,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(12,13): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(13,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(18,27): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(19,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(22,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(22,24): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(23,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(26,18): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(27,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. -==== arbitraryModuleNamespaceIdentifiers_es2015.ts (17 errors) ==== +==== arbitraryModuleNamespaceIdentifiers_module.ts (17 errors) ==== const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. - import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. if (valueX !== "someValue") throw "should be someValue"; - export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. - import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. if (valueY !== "someValue") throw "should be someValue"; - export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. - import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. if (valueZ[""] !== "someValue") throw "should be someValue"; @@ -52,29 +52,29 @@ arbitraryModuleNamespaceIdentifiers_es2015.ts(29,7): error TS2322: Type '"expect export { type someType as "" }; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. - import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. const importTest: typeA = "expect error about someType"; ~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. - import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. const reimportTest: typeB = "expect error about someType"; ~~~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. - import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ !!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).js similarity index 77% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.js rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).js index 0e388e43056de..4964f684a1ed0 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.js +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).js @@ -1,49 +1,49 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -//// [arbitraryModuleNamespaceIdentifiers_es2022.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.ts] const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; -//// [arbitraryModuleNamespaceIdentifiers_es2022.js] +//// [arbitraryModuleNamespaceIdentifiers_module.js] const someValue = "someValue"; export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") @@ -55,13 +55,13 @@ const reimportTest = "expect error about someType"; const importStarTestA = "expect error about otherType"; -//// [arbitraryModuleNamespaceIdentifiers_es2022.d.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] declare const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export { type someType as "" }; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).symbols similarity index 73% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.symbols rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).symbols index b45ab00dd143e..a792b7d3f5280 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.symbols +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).symbols @@ -1,82 +1,82 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -=== arbitraryModuleNamespaceIdentifiers_amd.ts === +=== arbitraryModuleNamespaceIdentifiers_module.ts === const someValue = "someValue"; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 0, 5)) +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) type someType = "someType"; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 0, 30)) +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) export { someValue as "" }; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 0, 5)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 3, 8)) +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 4, 8)) +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) if (valueX !== "someValue") throw "should be someValue"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 4, 8)) +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 7, 8)) +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 8, 8)) +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) if (valueY !== "someValue") throw "should be someValue"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 8, 8)) +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) -export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 11, 6)) +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 3, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 7, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) if (valueZ[""] !== valueZ) throw "should be export namespace"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 11, 6)) ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 12, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) export { type someType as "" }; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 0, 30)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 17, 8)) +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 18, 8)) +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) const importTest: typeA = "expect error about someType"; ->importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 19, 5)) ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 18, 8)) +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 21, 8)) +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 22, 8)) +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) const reimportTest: typeB = "expect error about someType"; ->reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 23, 5)) ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 22, 8)) +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 25, 11)) +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 26, 8)) +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) export type otherType = "otherType"; ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 26, 80)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) const importStarTestA: typeC.otherType = "expect error about otherType"; ->importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 28, 5)) ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 26, 8)) ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_amd.ts, 26, 80)) +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).types similarity index 89% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.types rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).types index 4455775b0f630..4574f9754d0b4 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2022.types +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).types @@ -1,6 +1,6 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -=== arbitraryModuleNamespaceIdentifiers_es2022.ts === +=== arbitraryModuleNamespaceIdentifiers_module.ts === const someValue = "someValue"; >someValue : "someValue" > : ^^^^^^^^^^^ @@ -17,7 +17,7 @@ export { someValue as "" }; >"" : "someValue" > : ^^^^^^^^^^^ -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueX : "someValue" > : ^^^^^^^^^^^ @@ -31,11 +31,11 @@ if (valueX !== "someValue") throw "should be someValue"; >"should be someValue" : "should be someValue" > : ^^^^^^^^^^^^^^^^^^^^^ -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : "someValue" > : ^^^^^^^^^^^ -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueY : "someValue" > : ^^^^^^^^^^^ @@ -49,11 +49,11 @@ if (valueY !== "someValue") throw "should be someValue"; >"should be someValue" : "should be someValue" > : ^^^^^^^^^^^^^^^^^^^^^ -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : typeof valueZ > : ^^^^^^^^^^^^^ -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueZ : typeof valueZ > : ^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ export { type someType as "" }; >"" : any > : ^^^ -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeA : any > : ^^^ @@ -115,11 +115,11 @@ const importTest: typeA = "expect error about someType"; >"expect error about someType" : "expect error about someType" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : any > : ^^^ -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeB : any > : ^^^ @@ -129,11 +129,11 @@ const reimportTest: typeB = "expect error about someType"; >"expect error about someType" : "expect error about someType" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : typeof valueZ > : ^^^^^^^^^^^^^ -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeC : typeof valueZ > : ^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).errors.txt similarity index 69% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.errors.txt rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).errors.txt index 40a1073537bb0..cc359bceb4904 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.errors.txt +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).errors.txt @@ -1,40 +1,40 @@ -arbitraryModuleNamespaceIdentifiers_amd.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_amd.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_amd.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. -==== arbitraryModuleNamespaceIdentifiers_amd.ts (3 errors) ==== +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; - import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; - export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; - import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; - export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; - import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; - import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; ~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; - import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; ~~~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; - import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).js new file mode 100644 index 0000000000000..4964f684a1ed0 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).js @@ -0,0 +1,67 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_module.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.js] +const someValue = "someValue"; +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueX !== "someValue") + throw "should be someValue"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueY !== "someValue") + throw "should be someValue"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== valueZ) + throw "should be export namespace"; +const importTest = "expect error about someType"; +const reimportTest = "expect error about someType"; +const importStarTestA = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).symbols similarity index 73% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.symbols rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).symbols index 3ed010475de9f..a792b7d3f5280 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.symbols +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).symbols @@ -1,82 +1,82 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -=== arbitraryModuleNamespaceIdentifiers_system.ts === +=== arbitraryModuleNamespaceIdentifiers_module.ts === const someValue = "someValue"; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 0, 5)) +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) type someType = "someType"; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 0, 30)) +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) export { someValue as "" }; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 0, 5)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 3, 8)) +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 4, 8)) +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) if (valueX !== "someValue") throw "should be someValue"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 4, 8)) +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 7, 8)) +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 8, 8)) +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) if (valueY !== "someValue") throw "should be someValue"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 8, 8)) +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) -export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 11, 6)) +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 3, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 7, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) if (valueZ[""] !== valueZ) throw "should be export namespace"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 11, 6)) ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 12, 8)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) export { type someType as "" }; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 0, 30)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 17, 8)) +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 18, 8)) +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) const importTest: typeA = "expect error about someType"; ->importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 19, 5)) ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 18, 8)) +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 21, 8)) +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 22, 8)) +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) const reimportTest: typeB = "expect error about someType"; ->reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 23, 5)) ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 22, 8)) +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 25, 11)) +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 26, 8)) +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) export type otherType = "otherType"; ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 26, 83)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) const importStarTestA: typeC.otherType = "expect error about otherType"; ->importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 28, 5)) ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 26, 8)) ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_system.ts, 26, 83)) +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).types similarity index 89% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.types rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).types index b536a77b75e89..4574f9754d0b4 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_amd.types +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2022).types @@ -1,6 +1,6 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -=== arbitraryModuleNamespaceIdentifiers_amd.ts === +=== arbitraryModuleNamespaceIdentifiers_module.ts === const someValue = "someValue"; >someValue : "someValue" > : ^^^^^^^^^^^ @@ -17,7 +17,7 @@ export { someValue as "" }; >"" : "someValue" > : ^^^^^^^^^^^ -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueX : "someValue" > : ^^^^^^^^^^^ @@ -31,11 +31,11 @@ if (valueX !== "someValue") throw "should be someValue"; >"should be someValue" : "should be someValue" > : ^^^^^^^^^^^^^^^^^^^^^ -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : "someValue" > : ^^^^^^^^^^^ -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueY : "someValue" > : ^^^^^^^^^^^ @@ -49,11 +49,11 @@ if (valueY !== "someValue") throw "should be someValue"; >"should be someValue" : "should be someValue" > : ^^^^^^^^^^^^^^^^^^^^^ -export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : typeof valueZ > : ^^^^^^^^^^^^^ -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; >valueZ : typeof valueZ > : ^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ export { type someType as "" }; >"" : any > : ^^^ -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeA : any > : ^^^ @@ -115,11 +115,11 @@ const importTest: typeA = "expect error about someType"; >"expect error about someType" : "expect error about someType" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : any > : ^^^ -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeB : any > : ^^^ @@ -129,11 +129,11 @@ const reimportTest: typeB = "expect error about someType"; >"expect error about someType" : "expect error about someType" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; >"" : typeof valueZ > : ^^^^^^^^^^^^^ -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; >typeC : typeof valueZ > : ^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).errors.txt new file mode 100644 index 0000000000000..01f0de2be6e68 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).errors.txt @@ -0,0 +1,84 @@ +arbitraryModuleNamespaceIdentifiers_module.ts(4,23): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(5,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(8,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(8,19): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(9,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(12,13): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(13,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(18,27): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(19,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(22,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(22,24): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(23,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(26,18): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(27,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_module.ts (17 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; + ~~~~~ +!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).js similarity index 77% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.js rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).js index b646c2549b0bc..d6a75c346d677 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_es2015.js +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).js @@ -1,50 +1,50 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -//// [arbitraryModuleNamespaceIdentifiers_es2015.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.ts] const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; -//// [arbitraryModuleNamespaceIdentifiers_es2015.js] +//// [arbitraryModuleNamespaceIdentifiers_module.js] const someValue = "someValue"; export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; -import * as _a from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import * as _a from "./arbitraryModuleNamespaceIdentifiers_module"; export { _a as "" }; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") @@ -56,13 +56,13 @@ const reimportTest = "expect error about someType"; const importStarTestA = "expect error about otherType"; -//// [arbitraryModuleNamespaceIdentifiers_es2015.d.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] declare const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export { type someType as "" }; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).symbols new file mode 100644 index 0000000000000..a792b7d3f5280 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).types new file mode 100644 index 0000000000000..4574f9754d0b4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).errors.txt similarity index 69% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.errors.txt rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).errors.txt index 364e2a6b3eb63..cc359bceb4904 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.errors.txt +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).errors.txt @@ -1,40 +1,40 @@ -arbitraryModuleNamespaceIdentifiers_umd.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_umd.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_umd.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. -==== arbitraryModuleNamespaceIdentifiers_umd.ts (3 errors) ==== +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; - import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; - export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; - import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; - export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; - import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; - import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; ~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; - import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; ~~~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. - export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; - import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).js new file mode 100644 index 0000000000000..4964f684a1ed0 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).js @@ -0,0 +1,67 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_module.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.js] +const someValue = "someValue"; +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueX !== "someValue") + throw "should be someValue"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueY !== "someValue") + throw "should be someValue"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== valueZ) + throw "should be export namespace"; +const importTest = "expect error about someType"; +const reimportTest = "expect error about someType"; +const importStarTestA = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).symbols new file mode 100644 index 0000000000000..a792b7d3f5280 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).types new file mode 100644 index 0000000000000..4574f9754d0b4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=esnext).types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).errors.txt new file mode 100644 index 0000000000000..cc359bceb4904 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).js new file mode 100644 index 0000000000000..d209a96d665e4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).js @@ -0,0 +1,94 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_module.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports[""] = exports[""] = exports[""] = void 0; +const someValue = "someValue"; +exports[""] = someValue; +const arbitraryModuleNamespaceIdentifiers_module_1 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_1[""] !== "someValue") + throw "should be someValue"; +var arbitraryModuleNamespaceIdentifiers_module_2 = require("./arbitraryModuleNamespaceIdentifiers_module"); +Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_module_2[""]; } }); +const arbitraryModuleNamespaceIdentifiers_module_3 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_3[""] !== "someValue") + throw "should be someValue"; +exports[""] = __importStar(require("./arbitraryModuleNamespaceIdentifiers_module")); +const arbitraryModuleNamespaceIdentifiers_module_4 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") + throw "should be someValue"; +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") + throw "should be someValue"; +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== arbitraryModuleNamespaceIdentifiers_module_4[""]) + throw "should be export namespace"; +const importTest = "expect error about someType"; +const reimportTest = "expect error about someType"; +const importStarTestA = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).symbols new file mode 100644 index 0000000000000..a792b7d3f5280 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).types new file mode 100644 index 0000000000000..4574f9754d0b4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=node16).types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).errors.txt new file mode 100644 index 0000000000000..cc359bceb4904 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).js new file mode 100644 index 0000000000000..d209a96d665e4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).js @@ -0,0 +1,94 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_module.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports[""] = exports[""] = exports[""] = void 0; +const someValue = "someValue"; +exports[""] = someValue; +const arbitraryModuleNamespaceIdentifiers_module_1 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_1[""] !== "someValue") + throw "should be someValue"; +var arbitraryModuleNamespaceIdentifiers_module_2 = require("./arbitraryModuleNamespaceIdentifiers_module"); +Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_module_2[""]; } }); +const arbitraryModuleNamespaceIdentifiers_module_3 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_3[""] !== "someValue") + throw "should be someValue"; +exports[""] = __importStar(require("./arbitraryModuleNamespaceIdentifiers_module")); +const arbitraryModuleNamespaceIdentifiers_module_4 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") + throw "should be someValue"; +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") + throw "should be someValue"; +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== arbitraryModuleNamespaceIdentifiers_module_4[""]) + throw "should be export namespace"; +const importTest = "expect error about someType"; +const reimportTest = "expect error about someType"; +const importStarTestA = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).symbols new file mode 100644 index 0000000000000..a792b7d3f5280 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).types new file mode 100644 index 0000000000000..4574f9754d0b4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=nodenext).types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).errors.txt new file mode 100644 index 0000000000000..cc359bceb4904 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).js new file mode 100644 index 0000000000000..43f95451590dc --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).js @@ -0,0 +1,71 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_module.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports[""] = exports[""] = exports[""] = void 0; +const someValue = "someValue"; +exports[""] = someValue; +const arbitraryModuleNamespaceIdentifiers_module_1 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_1[""] !== "someValue") + throw "should be someValue"; +var arbitraryModuleNamespaceIdentifiers_module_2 = require("./arbitraryModuleNamespaceIdentifiers_module"); +Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_module_2[""]; } }); +const arbitraryModuleNamespaceIdentifiers_module_3 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_3[""] !== "someValue") + throw "should be someValue"; +exports[""] = require("./arbitraryModuleNamespaceIdentifiers_module"); +const arbitraryModuleNamespaceIdentifiers_module_4 = require("./arbitraryModuleNamespaceIdentifiers_module"); +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") + throw "should be someValue"; +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") + throw "should be someValue"; +if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== arbitraryModuleNamespaceIdentifiers_module_4[""]) + throw "should be export namespace"; +const importTest = "expect error about someType"; +const reimportTest = "expect error about someType"; +const importStarTestA = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).symbols new file mode 100644 index 0000000000000..a792b7d3f5280 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).types new file mode 100644 index 0000000000000..4574f9754d0b4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=none).types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).errors.txt new file mode 100644 index 0000000000000..cc359bceb4904 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).js new file mode 100644 index 0000000000000..4964f684a1ed0 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).js @@ -0,0 +1,67 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +//// [arbitraryModuleNamespaceIdentifiers_module.ts] +const someValue = "someValue"; +type someType = "someType"; + +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueX !== "someValue") throw "should be someValue"; + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueY !== "someValue") throw "should be someValue"; + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== "someValue") throw "should be someValue"; +if (valueZ[""] !== valueZ) throw "should be export namespace"; + +export { type someType as "" }; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +const importTest: typeA = "expect error about someType"; + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +const reimportTest: typeB = "expect error about someType"; + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; +const importStarTestA: typeC.otherType = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.js] +const someValue = "someValue"; +export { someValue as "" }; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueX !== "someValue") + throw "should be someValue"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueY !== "someValue") + throw "should be someValue"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== "someValue") + throw "should be someValue"; +if (valueZ[""] !== valueZ) + throw "should be export namespace"; +const importTest = "expect error about someType"; +const reimportTest = "expect error about someType"; +const importStarTestA = "expect error about otherType"; + + +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] +declare const someValue = "someValue"; +type someType = "someType"; +export { someValue as "" }; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export { type someType as "" }; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).symbols new file mode 100644 index 0000000000000..a792b7d3f5280 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).types new file mode 100644 index 0000000000000..4574f9754d0b4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=preserve).types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).errors.txt new file mode 100644 index 0000000000000..cc359bceb4904 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).js similarity index 59% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.js rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).js index 9187258c7e4f9..c746a3ba3bf1d 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_system.js +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).js @@ -1,66 +1,66 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -//// [arbitraryModuleNamespaceIdentifiers_system.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.ts] const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; -//// [arbitraryModuleNamespaceIdentifiers_system.js] -System.register(["./arbitraryModuleNamespaceIdentifiers_system"], function (exports_1, context_1) { +//// [arbitraryModuleNamespaceIdentifiers_module.js] +System.register(["./arbitraryModuleNamespaceIdentifiers_module"], function (exports_1, context_1) { "use strict"; - var someValue, arbitraryModuleNamespaceIdentifiers_system_1, arbitraryModuleNamespaceIdentifiers_system_2, arbitraryModuleNamespaceIdentifiers_system_3, importTest, reimportTest, importStarTestA; + var someValue, arbitraryModuleNamespaceIdentifiers_module_1, arbitraryModuleNamespaceIdentifiers_module_2, arbitraryModuleNamespaceIdentifiers_module_3, importTest, reimportTest, importStarTestA; var __moduleName = context_1 && context_1.id; return { setters: [ - function (arbitraryModuleNamespaceIdentifiers_system_1_1) { - arbitraryModuleNamespaceIdentifiers_system_1 = arbitraryModuleNamespaceIdentifiers_system_1_1; + function (arbitraryModuleNamespaceIdentifiers_module_1_1) { + arbitraryModuleNamespaceIdentifiers_module_1 = arbitraryModuleNamespaceIdentifiers_module_1_1; exports_1({ - "": arbitraryModuleNamespaceIdentifiers_system_1_1[""] + "": arbitraryModuleNamespaceIdentifiers_module_1_1[""] }); - arbitraryModuleNamespaceIdentifiers_system_2 = arbitraryModuleNamespaceIdentifiers_system_1_1; - exports_1("", arbitraryModuleNamespaceIdentifiers_system_1_1); - arbitraryModuleNamespaceIdentifiers_system_3 = arbitraryModuleNamespaceIdentifiers_system_1_1; + arbitraryModuleNamespaceIdentifiers_module_2 = arbitraryModuleNamespaceIdentifiers_module_1_1; + exports_1("", arbitraryModuleNamespaceIdentifiers_module_1_1); + arbitraryModuleNamespaceIdentifiers_module_3 = arbitraryModuleNamespaceIdentifiers_module_1_1; } ], execute: function () { someValue = "someValue"; exports_1("", someValue); - if (arbitraryModuleNamespaceIdentifiers_system_1[""] !== "someValue") + if (arbitraryModuleNamespaceIdentifiers_module_1[""] !== "someValue") throw "should be someValue"; - if (arbitraryModuleNamespaceIdentifiers_system_2[""] !== "someValue") + if (arbitraryModuleNamespaceIdentifiers_module_2[""] !== "someValue") throw "should be someValue"; - if (arbitraryModuleNamespaceIdentifiers_system_3[""][""] !== "someValue") + if (arbitraryModuleNamespaceIdentifiers_module_3[""][""] !== "someValue") throw "should be someValue"; - if (arbitraryModuleNamespaceIdentifiers_system_3[""][""] !== "someValue") + if (arbitraryModuleNamespaceIdentifiers_module_3[""][""] !== "someValue") throw "should be someValue"; - if (arbitraryModuleNamespaceIdentifiers_system_3[""][""] !== arbitraryModuleNamespaceIdentifiers_system_3[""]) + if (arbitraryModuleNamespaceIdentifiers_module_3[""][""] !== arbitraryModuleNamespaceIdentifiers_module_3[""]) throw "should be export namespace"; importTest = "expect error about someType"; reimportTest = "expect error about someType"; @@ -70,13 +70,13 @@ System.register(["./arbitraryModuleNamespaceIdentifiers_system"], function (expo }); -//// [arbitraryModuleNamespaceIdentifiers_system.d.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] declare const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export { type someType as "" }; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).symbols new file mode 100644 index 0000000000000..a792b7d3f5280 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).types new file mode 100644 index 0000000000000..4574f9754d0b4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=system).types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).errors.txt new file mode 100644 index 0000000000000..cc359bceb4904 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).errors.txt @@ -0,0 +1,42 @@ +arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. +arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + + +==== arbitraryModuleNamespaceIdentifiers_module.ts (3 errors) ==== + const someValue = "someValue"; + type someType = "someType"; + + export { someValue as "" }; + import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueX !== "someValue") throw "should be someValue"; + + export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueY !== "someValue") throw "should be someValue"; + + export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== "someValue") throw "should be someValue"; + if (valueZ[""] !== valueZ) throw "should be export namespace"; + + export { type someType as "" }; + import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; + const importTest: typeA = "expect error about someType"; + ~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; + const reimportTest: typeB = "expect error about someType"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. + + export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; + import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; + export type otherType = "otherType"; + const importStarTestA: typeC.otherType = "expect error about otherType"; + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. + \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).js similarity index 59% rename from tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.js rename to tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).js index 045b5428f0621..a21466756821c 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.js +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).js @@ -1,45 +1,45 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts] //// +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// -//// [arbitraryModuleNamespaceIdentifiers_umd.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.ts] const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; -//// [arbitraryModuleNamespaceIdentifiers_umd.js] +//// [arbitraryModuleNamespaceIdentifiers_module.js] (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { - define(["require", "exports", "./arbitraryModuleNamespaceIdentifiers_umd", "./arbitraryModuleNamespaceIdentifiers_umd", "./arbitraryModuleNamespaceIdentifiers_umd", "./arbitraryModuleNamespaceIdentifiers_umd", "./arbitraryModuleNamespaceIdentifiers_umd"], factory); + define(["require", "exports", "./arbitraryModuleNamespaceIdentifiers_module", "./arbitraryModuleNamespaceIdentifiers_module", "./arbitraryModuleNamespaceIdentifiers_module", "./arbitraryModuleNamespaceIdentifiers_module", "./arbitraryModuleNamespaceIdentifiers_module"], factory); } })(function (require, exports) { "use strict"; @@ -47,21 +47,21 @@ const importStarTestA: typeC.otherType = "expect error about otherType"; exports[""] = exports[""] = exports[""] = void 0; const someValue = "someValue"; exports[""] = someValue; - const arbitraryModuleNamespaceIdentifiers_umd_1 = require("./arbitraryModuleNamespaceIdentifiers_umd"); - if (arbitraryModuleNamespaceIdentifiers_umd_1[""] !== "someValue") + const arbitraryModuleNamespaceIdentifiers_module_1 = require("./arbitraryModuleNamespaceIdentifiers_module"); + if (arbitraryModuleNamespaceIdentifiers_module_1[""] !== "someValue") throw "should be someValue"; - var arbitraryModuleNamespaceIdentifiers_umd_2 = require("./arbitraryModuleNamespaceIdentifiers_umd"); - Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_umd_2[""]; } }); - const arbitraryModuleNamespaceIdentifiers_umd_3 = require("./arbitraryModuleNamespaceIdentifiers_umd"); - if (arbitraryModuleNamespaceIdentifiers_umd_3[""] !== "someValue") + var arbitraryModuleNamespaceIdentifiers_module_2 = require("./arbitraryModuleNamespaceIdentifiers_module"); + Object.defineProperty(exports, "", { enumerable: true, get: function () { return arbitraryModuleNamespaceIdentifiers_module_2[""]; } }); + const arbitraryModuleNamespaceIdentifiers_module_3 = require("./arbitraryModuleNamespaceIdentifiers_module"); + if (arbitraryModuleNamespaceIdentifiers_module_3[""] !== "someValue") throw "should be someValue"; - exports[""] = require("./arbitraryModuleNamespaceIdentifiers_umd"); - const arbitraryModuleNamespaceIdentifiers_umd_4 = require("./arbitraryModuleNamespaceIdentifiers_umd"); - if (arbitraryModuleNamespaceIdentifiers_umd_4[""][""] !== "someValue") + exports[""] = require("./arbitraryModuleNamespaceIdentifiers_module"); + const arbitraryModuleNamespaceIdentifiers_module_4 = require("./arbitraryModuleNamespaceIdentifiers_module"); + if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") throw "should be someValue"; - if (arbitraryModuleNamespaceIdentifiers_umd_4[""][""] !== "someValue") + if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== "someValue") throw "should be someValue"; - if (arbitraryModuleNamespaceIdentifiers_umd_4[""][""] !== arbitraryModuleNamespaceIdentifiers_umd_4[""]) + if (arbitraryModuleNamespaceIdentifiers_module_4[""][""] !== arbitraryModuleNamespaceIdentifiers_module_4[""]) throw "should be export namespace"; const importTest = "expect error about someType"; const reimportTest = "expect error about someType"; @@ -69,13 +69,13 @@ const importStarTestA: typeC.otherType = "expect error about otherType"; }); -//// [arbitraryModuleNamespaceIdentifiers_umd.d.ts] +//// [arbitraryModuleNamespaceIdentifiers_module.d.ts] declare const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export { type someType as "" }; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).symbols new file mode 100644 index 0000000000000..a792b7d3f5280 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).symbols @@ -0,0 +1,82 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) + +type someType = "someType"; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) + +export { someValue as "" }; +>someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 5)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +if (valueX !== "someValue") throw "should be someValue"; +>valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 4, 8)) + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +if (valueY !== "someValue") throw "should be someValue"; +>valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 8, 8)) + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 3, 8)) + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 7, 8)) + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 11, 6)) +>valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 12, 8)) + +export { type someType as "" }; +>someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 0, 30)) +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 17, 8)) + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +const importTest: typeA = "expect error about someType"; +>importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 19, 5)) +>typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 18, 8)) + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 21, 8)) + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 23, 5)) +>typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 22, 8)) + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 25, 11)) + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) + +export type otherType = "otherType"; +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 28, 5)) +>typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 8)) +>otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_module.ts, 26, 83)) + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).types new file mode 100644 index 0000000000000..4574f9754d0b4 --- /dev/null +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=umd).types @@ -0,0 +1,151 @@ +//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts] //// + +=== arbitraryModuleNamespaceIdentifiers_module.ts === +const someValue = "someValue"; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ + +type someType = "someType"; +>someType : "someType" +> : ^^^^^^^^^^ + +export { someValue as "" }; +>someValue : "someValue" +> : ^^^^^^^^^^^ +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueX : "someValue" +> : ^^^^^^^^^^^ + +if (valueX !== "someValue") throw "should be someValue"; +>valueX !== "someValue" : boolean +> : ^^^^^^^ +>valueX : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : "someValue" +> : ^^^^^^^^^^^ + +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueY : "someValue" +> : ^^^^^^^^^^^ + +if (valueY !== "someValue") throw "should be someValue"; +>valueY !== "someValue" : boolean +> : ^^^^^^^ +>valueY : "someValue" +> : ^^^^^^^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== "someValue") throw "should be someValue"; +>valueZ[""] !== "someValue" : boolean +> : ^^^^^^^ +>valueZ[""] : "someValue" +> : ^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>"someValue" : "someValue" +> : ^^^^^^^^^^^ +>"should be someValue" : "should be someValue" +> : ^^^^^^^^^^^^^^^^^^^^^ + +if (valueZ[""] !== valueZ) throw "should be export namespace"; +>valueZ[""] !== valueZ : boolean +> : ^^^^^^^ +>valueZ[""] : typeof valueZ +> : ^^^^^^^^^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"" : "" +> : ^^^^^ +>valueZ : typeof valueZ +> : ^^^^^^^^^^^^^ +>"should be export namespace" : "should be export namespace" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type someType as "" }; +>someType : any +> : ^^^ +>"" : any +> : ^^^ + +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeA : any +> : ^^^ + +const importTest: typeA = "expect error about someType"; +>importTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : any +> : ^^^ + +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeB : any +> : ^^^ + +const reimportTest: typeB = "expect error about someType"; +>reimportTest : "someType" +> : ^^^^^^^^^^ +>"expect error about someType" : "expect error about someType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +>"" : typeof valueZ +> : ^^^^^^^^^^^^^ + +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; +>typeC : typeof valueZ +> : ^^^^^^^^^^^^^ + +export type otherType = "otherType"; +>otherType : "otherType" +> : ^^^^^^^^^^^ + +const importStarTestA: typeC.otherType = "expect error about otherType"; +>importStarTestA : "otherType" +> : ^^^^^^^^^^^ +>typeC : any +> : ^^^ +>"expect error about otherType" : "expect error about otherType" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.symbols deleted file mode 100644 index 9836582e00955..0000000000000 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.symbols +++ /dev/null @@ -1,82 +0,0 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts] //// - -=== arbitraryModuleNamespaceIdentifiers_umd.ts === -const someValue = "someValue"; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 0, 5)) - -type someType = "someType"; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 0, 30)) - -export { someValue as "" }; ->someValue : Symbol(someValue, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 0, 5)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 3, 8)) - -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 4, 8)) - -if (valueX !== "someValue") throw "should be someValue"; ->valueX : Symbol(valueX, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 4, 8)) - -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 7, 8)) - -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 8, 8)) - -if (valueY !== "someValue") throw "should be someValue"; ->valueY : Symbol(valueY, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 8, 8)) - -export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 11, 6)) - -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) - -if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 3, 8)) - -if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 7, 8)) - -if (valueZ[""] !== valueZ) throw "should be export namespace"; ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 11, 6)) ->valueZ : Symbol(valueZ, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 12, 8)) - -export { type someType as "" }; ->someType : Symbol(someType, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 0, 30)) ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 17, 8)) - -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 18, 8)) - -const importTest: typeA = "expect error about someType"; ->importTest : Symbol(importTest, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 19, 5)) ->typeA : Symbol(typeA, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 18, 8)) - -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 21, 8)) - -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 22, 8)) - -const reimportTest: typeB = "expect error about someType"; ->reimportTest : Symbol(reimportTest, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 23, 5)) ->typeB : Symbol(typeB, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 22, 8)) - -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; ->"" : Symbol(valueZ[""], Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 25, 11)) - -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 26, 8)) - -export type otherType = "otherType"; ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 26, 80)) - -const importStarTestA: typeC.otherType = "expect error about otherType"; ->importStarTestA : Symbol(importStarTestA, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 28, 5)) ->typeC : Symbol(typeC, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 26, 8)) ->otherType : Symbol(valueZ.otherType, Decl(arbitraryModuleNamespaceIdentifiers_umd.ts, 26, 80)) - diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.types deleted file mode 100644 index 7afb929842d69..0000000000000 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_umd.types +++ /dev/null @@ -1,151 +0,0 @@ -//// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts] //// - -=== arbitraryModuleNamespaceIdentifiers_umd.ts === -const someValue = "someValue"; ->someValue : "someValue" -> : ^^^^^^^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ - -type someType = "someType"; ->someType : "someType" -> : ^^^^^^^^^^ - -export { someValue as "" }; ->someValue : "someValue" -> : ^^^^^^^^^^^ ->"" : "someValue" -> : ^^^^^^^^^^^ - -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->valueX : "someValue" -> : ^^^^^^^^^^^ - -if (valueX !== "someValue") throw "should be someValue"; ->valueX !== "someValue" : boolean -> : ^^^^^^^ ->valueX : "someValue" -> : ^^^^^^^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ ->"should be someValue" : "should be someValue" -> : ^^^^^^^^^^^^^^^^^^^^^ - -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->"" : "someValue" -> : ^^^^^^^^^^^ - -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->valueY : "someValue" -> : ^^^^^^^^^^^ - -if (valueY !== "someValue") throw "should be someValue"; ->valueY !== "someValue" : boolean -> : ^^^^^^^ ->valueY : "someValue" -> : ^^^^^^^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ ->"should be someValue" : "should be someValue" -> : ^^^^^^^^^^^^^^^^^^^^^ - -export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; ->"" : typeof valueZ -> : ^^^^^^^^^^^^^ - -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ - -if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ[""] !== "someValue" : boolean -> : ^^^^^^^ ->valueZ[""] : "someValue" -> : ^^^^^^^^^^^ ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ ->"" : "" -> : ^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ ->"should be someValue" : "should be someValue" -> : ^^^^^^^^^^^^^^^^^^^^^ - -if (valueZ[""] !== "someValue") throw "should be someValue"; ->valueZ[""] !== "someValue" : boolean -> : ^^^^^^^ ->valueZ[""] : "someValue" -> : ^^^^^^^^^^^ ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ ->"" : "" -> : ^^^^^ ->"someValue" : "someValue" -> : ^^^^^^^^^^^ ->"should be someValue" : "should be someValue" -> : ^^^^^^^^^^^^^^^^^^^^^ - -if (valueZ[""] !== valueZ) throw "should be export namespace"; ->valueZ[""] !== valueZ : boolean -> : ^^^^^^^ ->valueZ[""] : typeof valueZ -> : ^^^^^^^^^^^^^ ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ ->"" : "" -> : ^^^^^ ->valueZ : typeof valueZ -> : ^^^^^^^^^^^^^ ->"should be export namespace" : "should be export namespace" -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -export { type someType as "" }; ->someType : any -> : ^^^ ->"" : any -> : ^^^ - -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->typeA : any -> : ^^^ - -const importTest: typeA = "expect error about someType"; ->importTest : "someType" -> : ^^^^^^^^^^ ->"expect error about someType" : "expect error about someType" -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->"" : any -> : ^^^ - -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->typeB : any -> : ^^^ - -const reimportTest: typeB = "expect error about someType"; ->reimportTest : "someType" -> : ^^^^^^^^^^ ->"expect error about someType" : "expect error about someType" -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; ->"" : typeof valueZ -> : ^^^^^^^^^^^^^ - -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; ->typeC : typeof valueZ -> : ^^^^^^^^^^^^^ - -export type otherType = "otherType"; ->otherType : "otherType" -> : ^^^^^^^^^^^ - -const importStarTestA: typeC.otherType = "expect error about otherType"; ->importStarTestA : "otherType" -> : ^^^^^^^^^^^ ->typeC : any -> : ^^^ ->"expect error about otherType" : "expect error about otherType" -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts deleted file mode 100644 index bb2c6113b07b0..0000000000000 --- a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_amd.ts +++ /dev/null @@ -1,33 +0,0 @@ -//@module: AMD -//@target: ES2022 -//@declaration: true - -const someValue = "someValue"; -type someType = "someType"; - -export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_amd"; -if (valueX !== "someValue") throw "should be someValue"; - -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_amd"; -if (valueY !== "someValue") throw "should be someValue"; - -export * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_amd"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== valueZ) throw "should be export namespace"; - -export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_amd"; -const importTest: typeA = "expect error about someType"; - -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_amd"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_amd"; -const reimportTest: typeB = "expect error about someType"; - -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_amd"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_amd"; -export type otherType = "otherType"; -const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts deleted file mode 100644 index b94b5cc978eb5..0000000000000 --- a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_commonjs.ts +++ /dev/null @@ -1,33 +0,0 @@ -//@module: CommonJS -//@target: ES2022 -//@declaration: true - -const someValue = "someValue"; -type someType = "someType"; - -export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -if (valueX !== "someValue") throw "should be someValue"; - -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -if (valueY !== "someValue") throw "should be someValue"; - -export * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== valueZ) throw "should be export namespace"; - -export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -const importTest: typeA = "expect error about someType"; - -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -const reimportTest: typeB = "expect error about someType"; - -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_commonjs"; -export type otherType = "otherType"; -const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts deleted file mode 100644 index fbe39ff6aea8e..0000000000000 --- a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2015.ts +++ /dev/null @@ -1,33 +0,0 @@ -//@module: ES2015 -//@target: ESNext -//@declaration: true - -const someValue = "someValue"; -type someType = "someType"; - -export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -if (valueX !== "someValue") throw "should be someValue"; - -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -if (valueY !== "someValue") throw "should be someValue"; - -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== valueZ) throw "should be export namespace"; - -export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -const importTest: typeA = "expect error about someType"; - -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -const reimportTest: typeB = "expect error about someType"; - -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2015"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2015"; -export type otherType = "otherType"; -const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts deleted file mode 100644 index 3eb638d398d38..0000000000000 --- a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_es2022.ts +++ /dev/null @@ -1,33 +0,0 @@ -//@module: ES2022 -//@target: ES2022 -//@declaration: true - -const someValue = "someValue"; -type someType = "someType"; - -export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -if (valueX !== "someValue") throw "should be someValue"; - -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -if (valueY !== "someValue") throw "should be someValue"; - -export * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== valueZ) throw "should be export namespace"; - -export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -const importTest: typeA = "expect error about someType"; - -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -const reimportTest: typeB = "expect error about someType"; - -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_es2022"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_es2022"; -export type otherType = "otherType"; -const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts similarity index 84% rename from tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts rename to tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts index 749a288bfe905..e69f71ef71794 100644 --- a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_umd.ts +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_module.ts @@ -1,4 +1,4 @@ -//@module: UMD +//@module: * //@target: ES2022 //@declaration: true @@ -6,28 +6,28 @@ const someValue = "someValue"; type someType = "someType"; export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueX !== "someValue") throw "should be someValue"; -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueY !== "someValue") throw "should be someValue"; -export * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_umd"; +import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; const importTest: typeA = "expect error about someType"; -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_umd"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; const reimportTest: typeB = "expect error about someType"; -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_umd"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_umd"; +export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; +import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts deleted file mode 100644 index ffbcf600faf99..0000000000000 --- a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_system.ts +++ /dev/null @@ -1,33 +0,0 @@ -//@module: System -//@target: ES2022 -//@declaration: true - -const someValue = "someValue"; -type someType = "someType"; - -export { someValue as "" }; -import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_system"; -if (valueX !== "someValue") throw "should be someValue"; - -export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; -import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_system"; -if (valueY !== "someValue") throw "should be someValue"; - -export * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; -import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_system"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== "someValue") throw "should be someValue"; -if (valueZ[""] !== valueZ) throw "should be export namespace"; - -export { type someType as "" }; -import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_system"; -const importTest: typeA = "expect error about someType"; - -export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_system"; -import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_system"; -const reimportTest: typeB = "expect error about someType"; - -export type * as "" from "./arbitraryModuleNamespaceIdentifiers_system"; -import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_system"; -export type otherType = "otherType"; -const importStarTestA: typeC.otherType = "expect error about otherType"; From 05e4a89db191c8f35decd10a2ac2f63c63df6c10 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 29 May 2024 20:55:07 -0400 Subject: [PATCH 07/11] "string literal import and export names" message --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- ...entifiers_module(module=es2020).errors.txt | 56 +++++++++---------- ...eIdentifiers_module(module=es6).errors.txt | 56 +++++++++---------- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 931370f232386..ef83fe8ab8be0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -46568,7 +46568,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function checkModuleExportName(name: ModuleExportName | undefined) { if (name !== undefined && name.kind === SyntaxKind.StringLiteral && (moduleKind === ModuleKind.ES2015 || moduleKind === ModuleKind.ES2020)) { - grammarErrorOnNode(name, Diagnostics.Arbitrary_module_namespace_identifiers_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020); + grammarErrorOnNode(name, Diagnostics.String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c63f2b36d1d32..7e6c4feafc9cc 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -8318,7 +8318,7 @@ "category": "Error", "code": 18056 }, - "Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'.": { + "String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'.": { "category": "Error", "code": 18057 } diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).errors.txt index 01f0de2be6e68..e2a851b5a7bd3 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).errors.txt +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es2020).errors.txt @@ -1,19 +1,19 @@ -arbitraryModuleNamespaceIdentifiers_module.ts(4,23): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(5,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(8,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(8,19): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(9,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(12,13): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(13,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(18,27): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(19,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(4,23): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(5,10): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(8,10): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(8,19): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(9,10): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(12,13): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(13,10): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(18,27): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(19,15): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_module.ts(22,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(22,24): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(23,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(22,15): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(22,24): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(23,15): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_module.ts(26,18): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(27,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(26,18): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(27,15): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. @@ -23,60 +23,60 @@ arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect export { someValue as "" }; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. if (valueX !== "someValue") throw "should be someValue"; export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. if (valueY !== "someValue") throw "should be someValue"; export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. const importTest: typeA = "expect error about someType"; ~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. const reimportTest: typeB = "expect error about someType"; ~~~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).errors.txt index 01f0de2be6e68..e2a851b5a7bd3 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).errors.txt +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_module(module=es6).errors.txt @@ -1,19 +1,19 @@ -arbitraryModuleNamespaceIdentifiers_module.ts(4,23): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(5,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(8,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(8,19): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(9,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(12,13): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(13,10): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(18,27): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(19,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(4,23): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(5,10): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(8,10): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(8,19): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(9,10): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(12,13): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(13,10): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(18,27): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(19,15): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. arbitraryModuleNamespaceIdentifiers_module.ts(20,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_module.ts(22,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(22,24): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(23,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(22,15): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(22,24): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(23,15): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. arbitraryModuleNamespaceIdentifiers_module.ts(24,7): error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. -arbitraryModuleNamespaceIdentifiers_module.ts(26,18): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. -arbitraryModuleNamespaceIdentifiers_module.ts(27,15): error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(26,18): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +arbitraryModuleNamespaceIdentifiers_module.ts(27,15): error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect error about otherType"' is not assignable to type '"otherType"'. @@ -23,60 +23,60 @@ arbitraryModuleNamespaceIdentifiers_module.ts(29,7): error TS2322: Type '"expect export { someValue as "" }; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { "" as valueX } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. if (valueX !== "someValue") throw "should be someValue"; export { "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { "" as valueY } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. if (valueY !== "someValue") throw "should be someValue"; export * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { "" as valueZ } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== "someValue") throw "should be someValue"; if (valueZ[""] !== valueZ) throw "should be export namespace"; export { type someType as "" }; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { type "" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. const importTest: typeA = "expect error about someType"; ~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. export { type "" as "" } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { type "" as typeB } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. const reimportTest: typeB = "expect error about someType"; ~~~~~~~~~~~~ !!! error TS2322: Type '"expect error about someType"' is not assignable to type '"someType"'. export type * as "" from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. import { type "" as typeC } from "./arbitraryModuleNamespaceIdentifiers_module"; ~~~~~ -!!! error TS18057: Arbitrary module namespace identifiers are not supported when the '--module' flag is set to 'es2015' or 'es2020'. +!!! error TS18057: String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'. export type otherType = "otherType"; const importStarTestA: typeC.otherType = "expect error about otherType"; ~~~~~~~~~~~~~~~ From 03fc9d6f37928e0d6b66536eaaa15bda2fb9067c Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 29 May 2024 21:05:21 -0400 Subject: [PATCH 08/11] address common subexpression elimination comments --- src/compiler/transformers/module/module.ts | 26 +++++++--------------- src/compiler/transformers/module/system.ts | 22 +++++------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 5126ff6cda886..52b07a8c4493d 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1623,19 +1623,14 @@ export function transformModule(context: TransformationContext): (x: SourceFile ); } for (const specifier of node.exportClause.elements) { + const specifierName = specifier.propertyName || specifier.name; const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & InternalEmitFlags.NeverApplyImportHelper) && - moduleExportNameIsDefault(specifier.propertyName || specifier.name); - const specifierName = specifier.propertyName || specifier.name; + moduleExportNameIsDefault(specifierName); + const target = exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName; const exportedValue = specifierName.kind === SyntaxKind.StringLiteral - ? factory.createElementAccessExpression( - exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, - specifierName, - ) - : factory.createPropertyAccessExpression( - exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, - specifierName, - ); + ? factory.createElementAccessExpression(target, specifierName) + : factory.createPropertyAccessExpression(target, specifierName); statements.push( setOriginalNode( setTextRange( @@ -2374,16 +2369,11 @@ export function transformModule(context: TransformationContext): (x: SourceFile } else if (isImportSpecifier(importDeclaration)) { const name = importDeclaration.propertyName || importDeclaration.name; + const target = factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration); return setTextRange( name.kind === SyntaxKind.StringLiteral - ? factory.createElementAccessExpression( - factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), - factory.cloneNode(name), - ) - : factory.createPropertyAccessExpression( - factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), - factory.cloneNode(name), - ), + ? factory.createElementAccessExpression(target, factory.cloneNode(name)) + : factory.createPropertyAccessExpression(target, factory.cloneNode(name)), /*location*/ node, ); } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 9f18140f3f3ed..3d4bd039a2191 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1857,18 +1857,13 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc } else if (isImportSpecifier(importDeclaration)) { const importedName = importDeclaration.propertyName || importDeclaration.name; + const target = factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration); return setTextRange( factory.createPropertyAssignment( factory.cloneNode(name), importedName.kind === SyntaxKind.StringLiteral - ? factory.createElementAccessExpression( - factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), - factory.cloneNode(importedName), - ) - : factory.createPropertyAccessExpression( - factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), - factory.cloneNode(importedName), - ), + ? factory.createElementAccessExpression(target, factory.cloneNode(importedName)) + : factory.createPropertyAccessExpression(target, factory.cloneNode(importedName)), ), /*location*/ node, ); @@ -1931,16 +1926,11 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc } else if (isImportSpecifier(importDeclaration)) { const importedName = importDeclaration.propertyName || importDeclaration.name; + const target = factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration); return setTextRange( importedName.kind === SyntaxKind.StringLiteral - ? factory.createElementAccessExpression( - factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), - factory.cloneNode(importedName), - ) - : factory.createPropertyAccessExpression( - factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), - factory.cloneNode(importedName), - ), + ? factory.createElementAccessExpression(target, factory.cloneNode(importedName)) + : factory.createPropertyAccessExpression(target, factory.cloneNode(importedName)), /*location*/ node, ); } From 5f9c0abf10b5e8377b1c43d47d1623bb5355528c Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 29 May 2024 21:22:00 -0400 Subject: [PATCH 09/11] move identifier generation into `completions.ts` --- src/compiler/scanner.ts | 24 ------------------------ src/services/completions.ts | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 3578aae3b8888..5d93e57ebe660 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -997,30 +997,6 @@ export function isIdentifierText(name: string, languageVersion: ScriptTarget | u return true; } -/** @internal */ -export function generateIdentifierForArbitraryString(text: string, languageVersion: ScriptTarget | undefined): string { - let needsUnderscore = false; - let identifier = ""; - let ch: number; - - // Convert "(example, text)" into "_example_text_" - for (let i = 0; i < text.length; i += charSize(ch)) { - ch = codePointAt(text, i); - if (i === 0 ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion)) { - if (needsUnderscore) identifier += "_"; - identifier += String.fromCodePoint(ch); - needsUnderscore = false; - } - else { - needsUnderscore = true; - } - } - if (needsUnderscore) identifier += "_"; - - // Default to "_" if the provided text was empty - return identifier || "_"; -} - const enum ClassSetExpressionType { Unknown, ClassUnion, diff --git a/src/services/completions.ts b/src/services/completions.ts index 8437c72ae8878..bca032995c99d 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -75,7 +75,6 @@ import { formatting, FunctionLikeDeclaration, FutureSymbolExportInfo, - generateIdentifierForArbitraryString, getAllSuperTypeNodes, getAncestor, getCombinedLocalAndExportSymbolFlags, @@ -171,6 +170,8 @@ import { isFunctionTypeNode, isGetAccessorDeclaration, isIdentifier, + isIdentifierPart, + isIdentifierStart, isIdentifierText, isImportableFile, isImportAttributes, @@ -1883,6 +1884,29 @@ function createCompletionEntry( }; } +function generateIdentifierForArbitraryString(text: string, languageVersion: ScriptTarget | undefined): string { + let needsUnderscore = false; + let identifier = ""; + let ch: number | undefined; + + // Convert "(example, text)" into "_example_text_" + for (let i = 0; i < text.length; i += ch !== undefined && ch >= 0x10000 ? 2 : 1) { + ch = text.codePointAt(i); + if (ch !== undefined && (i === 0 ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (needsUnderscore) identifier += "_"; + identifier += String.fromCodePoint(ch); + needsUnderscore = false; + } + else { + needsUnderscore = true; + } + } + if (needsUnderscore) identifier += "_"; + + // Default to "_" if the provided text was empty + return identifier || "_"; +} + function isClassLikeMemberCompletion(symbol: Symbol, location: Node, sourceFile: SourceFile): boolean { // TODO: support JS files. if (isInJSFile(location)) { From 392d944a43b301a50c97b782896338f5ee4b0ded Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 29 May 2024 21:43:53 -0400 Subject: [PATCH 10/11] various parser fixes --- src/compiler/checker.ts | 15 +- src/compiler/parser.ts | 59 +++---- ...duleNamespaceIdentifiers_syntax.errors.txt | 131 +++++++++------ ...itraryModuleNamespaceIdentifiers_syntax.js | 156 ++++++++++++------ ...yModuleNamespaceIdentifiers_syntax.symbols | 144 +++++++++------- ...aryModuleNamespaceIdentifiers_syntax.types | 115 ++++++++----- ...itraryModuleNamespaceIdentifiers_syntax.ts | 73 ++++---- 7 files changed, 422 insertions(+), 271 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ef83fe8ab8be0..29dc35b44351c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -46566,8 +46566,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return true; } - function checkModuleExportName(name: ModuleExportName | undefined) { - if (name !== undefined && name.kind === SyntaxKind.StringLiteral && (moduleKind === ModuleKind.ES2015 || moduleKind === ModuleKind.ES2020)) { + function checkModuleExportName(name: ModuleExportName | undefined, allowStringLiteral = true) { + if (name === undefined || name.kind !== SyntaxKind.StringLiteral) { + return; + } + if (!allowStringLiteral) { + grammarErrorOnNode(name, Diagnostics.Identifier_expected); + } + else if (moduleKind === ModuleKind.ES2015 || moduleKind === ModuleKind.ES2020) { grammarErrorOnNode(name, Diagnostics.String_literal_import_and_export_names_are_not_supported_when_the_module_flag_is_set_to_es2015_or_es2020); } } @@ -46955,12 +46961,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function checkExportSpecifier(node: ExportSpecifier) { checkAliasSymbol(node); - checkModuleExportName(node.propertyName); + const hasModuleSpecifier = node.parent.parent.moduleSpecifier !== undefined; + checkModuleExportName(node.propertyName, hasModuleSpecifier); checkModuleExportName(node.name); if (getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); } - if (!node.parent.parent.moduleSpecifier) { + if (!hasModuleSpecifier) { const exportedName = node.propertyName || node.name; if (exportedName.kind === SyntaxKind.StringLiteral) { return; // Skip for invalid syntax like this: export { "x" } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3c2956954a9b9..2fcfa216665cf 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -8513,6 +8513,10 @@ namespace Parser { return finishNode(factory.createNamespaceImport(name), pos); } + function canParseModuleExportName(): boolean { + return tokenIsIdentifierOrKeyword(token()) || token() === SyntaxKind.StringLiteral; + } + function parseModuleExportName(parseName: () => Identifier): ModuleExportName { return token() === SyntaxKind.StringLiteral ? parseLiteralNode() as StringLiteral : parseName(); } @@ -8574,11 +8578,12 @@ namespace Parser { if (token() === SyntaxKind.AsKeyword) { // { type as as ...? } const secondAs = parseIdentifierName(); - if (tokenIsIdentifierOrKeyword(token())) { + if (canParseModuleExportName()) { // { type as as something } + // { type as as "something" } isTypeOnly = true; propertyName = firstAs; - name = parseNameWithKeywordCheck(); + name = parseModuleExportName(parseNameWithKeywordCheck); canParseAsKeyword = false; } else { @@ -8588,11 +8593,12 @@ namespace Parser { canParseAsKeyword = false; } } - else if (tokenIsIdentifierOrKeyword(token())) { + else if (canParseModuleExportName()) { // { type as something } + // { type as "something" } propertyName = name; canParseAsKeyword = false; - name = parseNameWithKeywordCheck(); + name = parseModuleExportName(parseNameWithKeywordCheck); } else { // { type as } @@ -8600,25 +8606,28 @@ namespace Parser { name = firstAs; } } - else if (token() === SyntaxKind.StringLiteral) { - // { type "something" as ... } - isTypeOnly = true; - name = parseLiteralNode() as StringLiteral; - } - else if (tokenIsIdentifierOrKeyword(token())) { + else if (canParseModuleExportName()) { // { type something ...? } + // { type "something" ...? } isTypeOnly = true; - name = parseNameWithKeywordCheck(); + name = parseModuleExportName(parseNameWithKeywordCheck); } } - if ((kind === SyntaxKind.ImportSpecifier && name.kind === SyntaxKind.StringLiteral) || (canParseAsKeyword && token() === SyntaxKind.AsKeyword)) { + if (canParseAsKeyword && token() === SyntaxKind.AsKeyword) { propertyName = name; parseExpected(SyntaxKind.AsKeyword); name = parseModuleExportName(parseNameWithKeywordCheck); } - if (kind === SyntaxKind.ImportSpecifier && checkIdentifierIsKeyword) { - parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected); + if (kind === SyntaxKind.ImportSpecifier) { + if (name.kind !== SyntaxKind.Identifier) { + // ImportSpecifier casts "name" to Identifier below, so make sure it's an identifier + parseErrorAt(skipTrivia(sourceText, name.pos), name.end, Diagnostics.Identifier_expected); + name = setTextRangePosEnd(createMissingNode(SyntaxKind.Identifier, /* reportAtCurrentPosition */ false), name.pos, name.pos); + } + else if (checkIdentifierIsKeyword) { + parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected); + } } const node = kind === SyntaxKind.ImportSpecifier ? factory.createImportSpecifier(isTypeOnly, propertyName, name as Identifier) @@ -8666,28 +8675,6 @@ namespace Parser { if (moduleSpecifier && (currentToken === SyntaxKind.WithKeyword || currentToken === SyntaxKind.AssertKeyword) && !scanner.hasPrecedingLineBreak()) { attributes = parseImportAttributes(currentToken); } - - // String literals are only allowed in the export specifiers if there's - // a module present: - // - // // Valid: - // export { "x" } from "foo"; - // export { "x" as y } from "foo"; - // export { x as "y" }; - // - // // Invalid: - // export { "x" }; - // export { "x" as y }; - // - if (exportClause && exportClause.kind === SyntaxKind.NamedExports && !moduleSpecifier) { - for (const element of exportClause.elements) { - const name = element.propertyName || element.name; - if (name.kind === SyntaxKind.StringLiteral) { - parseErrorAt(skipTrivia(sourceText, name.pos), name.end, Diagnostics.Identifier_expected); - } - } - } - parseSemicolon(); setAwaitContext(savedAwaitContext); const node = factory.createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, attributes); diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.errors.txt b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.errors.txt index 4468d9a48cf1a..e5307689df328 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.errors.txt +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.errors.txt @@ -1,70 +1,107 @@ -types1.ts(10,15): error TS2305: Module '"./types1"' has no exported member '"invalid 1"'. -types1.ts(10,27): error TS1005: 'as' expected. -types1.ts(12,15): error TS1003: Identifier expected. -types2.ts(9,15): error TS2305: Module '"./types2"' has no exported member '"invalid 1"'. -types2.ts(9,27): error TS1005: 'as' expected. -types2.ts(11,15): error TS1003: Identifier expected. -values.ts(10,10): error TS2305: Module '"./values"' has no exported member '"invalid 1"'. -values.ts(10,22): error TS1005: 'as' expected. -values.ts(12,10): error TS1003: Identifier expected. +type-clause-bad-export.ts(1,15): error TS1003: Identifier expected. +type-clause-bad-import.ts(1,22): error TS1003: Identifier expected. +type-clause-no-as.ts(1,15): error TS1003: Identifier expected. +type-clause-type-as-as.ts(1,15): error TS2305: Module '"./type-clause-valid"' has no exported member 'as'. +type-clause-type-as-as.ts(1,21): error TS1003: Identifier expected. +type-decls-bad-export.ts(1,15): error TS1003: Identifier expected. +type-decls-bad-import.ts(1,22): error TS1003: Identifier expected. +type-decls-no-as.ts(1,15): error TS1003: Identifier expected. +type-decls-type-as.ts(1,15): error TS2305: Module '"./type-decls-valid"' has no exported member 'type'. +type-decls-type-as.ts(1,23): error TS1003: Identifier expected. +values-bad-export.ts(1,10): error TS1003: Identifier expected. +values-bad-import.ts(1,17): error TS1003: Identifier expected. +values-no-as.ts(1,10): error TS1003: Identifier expected. +values-type-as.ts(1,10): error TS2305: Module '"./values-valid"' has no exported member 'type'. +values-type-as.ts(1,18): error TS1003: Identifier expected. -==== values.ts (3 errors) ==== - // Valid +==== values-valid.ts (0 errors) ==== export const foo = 123; export { foo as "valid 1" }; - import { "valid 1" as bar } from "./values"; - export { "valid 1" as "valid 2" } from "./values"; - export { foo as "valid 3" } from "./values"; - export * as "valid 4" from "./values"; + import { "valid 1" as bar } from "./values-valid"; + export { "valid 1" as "valid 2" } from "./values-valid"; + export { foo as "valid 3" } from "./values-valid"; + export * as "valid 4" from "./values-valid"; - // Invalid - import { "invalid 1" } from "./values"; - ~~~~~~~~~~~ -!!! error TS2305: Module '"./values"' has no exported member '"invalid 1"'. - ~ -!!! error TS1005: 'as' expected. - import { foo as "invalid 2" } from "./values"; +==== values-bad-import.ts (1 errors) ==== + import { foo as "invalid 2" } from "./values-valid"; + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + +==== values-bad-export.ts (1 errors) ==== export { "invalid 3" as baz }; ~~~~~~~~~~~ !!! error TS1003: Identifier expected. -==== types1.ts (3 errors) ==== - // Valid +==== values-no-as.ts (1 errors) ==== + import { "invalid 1" } from "./values-valid"; + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + +==== values-type-as.ts (2 errors) ==== + import { type as "invalid 4" } from "./values-valid"; + ~~~~ +!!! error TS2305: Module '"./values-valid"' has no exported member 'type'. + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + + +==== type-decls-valid.ts (0 errors) ==== export type foo = 123; export type { foo as "valid 1" }; - import type { "valid 1" as bar } from "./types1"; - export type { "valid 1" as "valid 2" } from "./types1"; - export type { foo as "valid 3" } from "./types1"; - export type * as "valid 4" from "./types1"; + import type { "valid 1" as bar } from "./type-decls-valid"; + export type { "valid 1" as "valid 2" } from "./type-decls-valid"; + export type { foo as "valid 3" } from "./type-decls-valid"; + export type * as "valid 4" from "./type-decls-valid"; - // Invalid - import type { "invalid 1" } from "./types1"; - ~~~~~~~~~~~ -!!! error TS2305: Module '"./types1"' has no exported member '"invalid 1"'. - ~ -!!! error TS1005: 'as' expected. - import type { foo as "invalid 2" } from "./types1"; +==== type-decls-bad-import.ts (1 errors) ==== + import type { foo as "invalid 2" } from "./type-decls-valid"; + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + +==== type-decls-bad-export.ts (1 errors) ==== export type { "invalid 3" as baz }; ~~~~~~~~~~~ !!! error TS1003: Identifier expected. -==== types2.ts (3 errors) ==== - // Valid +==== type-decls-no-as.ts (1 errors) ==== + import type { "invalid 1" } from "./type-decls-valid"; + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + +==== type-decls-type-as.ts (2 errors) ==== + import type { type as "invalid 4" } from "./type-decls-valid"; + ~~~~ +!!! error TS2305: Module '"./type-decls-valid"' has no exported member 'type'. + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + +==== type-clause-valid.ts (0 errors) ==== export type foo = 123; export { type foo as "valid 1" }; - import { type "valid 1" as bar } from "./types2"; - export { type "valid 1" as "valid 2" } from "./types2"; - export { type foo as "valid 3" } from "./types2"; + import { type "valid 1" as bar } from "./type-clause-valid"; + export { type "valid 1" as "valid 2" } from "./type-clause-valid"; + export { type foo as "valid 3" } from "./type-clause-valid"; - // Invalid - import { type "invalid 1" } from "./types2"; - ~~~~~~~~~~~ -!!! error TS2305: Module '"./types2"' has no exported member '"invalid 1"'. - ~ -!!! error TS1005: 'as' expected. - import { type foo as "invalid 2" } from "./types2"; +==== type-clause-bad-import.ts (1 errors) ==== + import { type foo as "invalid 2" } from "./type-clause-valid"; + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + +==== type-clause-bad-export.ts (1 errors) ==== export { type "invalid 3" as baz }; ~~~~~~~~~~~ !!! error TS1003: Identifier expected. + +==== type-clause-no-as.ts (1 errors) ==== + import { type "invalid 1" } from "./type-clause-valid"; + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. + +==== type-clause-type-as-as.ts (2 errors) ==== + import { type as as "invalid 4" } from "./type-clause-valid"; + ~~ +!!! error TS2305: Module '"./type-clause-valid"' has no exported member 'as'. + ~~~~~~~~~~~ +!!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.js b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.js index 199c018695a71..03103be74bf13 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.js +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.js @@ -1,78 +1,140 @@ //// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts] //// -//// [values.ts] -// Valid +//// [values-valid.ts] export const foo = 123; export { foo as "valid 1" }; -import { "valid 1" as bar } from "./values"; -export { "valid 1" as "valid 2" } from "./values"; -export { foo as "valid 3" } from "./values"; -export * as "valid 4" from "./values"; - -// Invalid -import { "invalid 1" } from "./values"; -import { foo as "invalid 2" } from "./values"; +import { "valid 1" as bar } from "./values-valid"; +export { "valid 1" as "valid 2" } from "./values-valid"; +export { foo as "valid 3" } from "./values-valid"; +export * as "valid 4" from "./values-valid"; + +//// [values-bad-import.ts] +import { foo as "invalid 2" } from "./values-valid"; + +//// [values-bad-export.ts] export { "invalid 3" as baz }; -//// [types1.ts] -// Valid +//// [values-no-as.ts] +import { "invalid 1" } from "./values-valid"; + +//// [values-type-as.ts] +import { type as "invalid 4" } from "./values-valid"; + + +//// [type-decls-valid.ts] export type foo = 123; export type { foo as "valid 1" }; -import type { "valid 1" as bar } from "./types1"; -export type { "valid 1" as "valid 2" } from "./types1"; -export type { foo as "valid 3" } from "./types1"; -export type * as "valid 4" from "./types1"; - -// Invalid -import type { "invalid 1" } from "./types1"; -import type { foo as "invalid 2" } from "./types1"; +import type { "valid 1" as bar } from "./type-decls-valid"; +export type { "valid 1" as "valid 2" } from "./type-decls-valid"; +export type { foo as "valid 3" } from "./type-decls-valid"; +export type * as "valid 4" from "./type-decls-valid"; + +//// [type-decls-bad-import.ts] +import type { foo as "invalid 2" } from "./type-decls-valid"; + +//// [type-decls-bad-export.ts] export type { "invalid 3" as baz }; -//// [types2.ts] -// Valid +//// [type-decls-no-as.ts] +import type { "invalid 1" } from "./type-decls-valid"; + +//// [type-decls-type-as.ts] +import type { type as "invalid 4" } from "./type-decls-valid"; + +//// [type-clause-valid.ts] export type foo = 123; export { type foo as "valid 1" }; -import { type "valid 1" as bar } from "./types2"; -export { type "valid 1" as "valid 2" } from "./types2"; -export { type foo as "valid 3" } from "./types2"; - -// Invalid -import { type "invalid 1" } from "./types2"; -import { type foo as "invalid 2" } from "./types2"; +import { type "valid 1" as bar } from "./type-clause-valid"; +export { type "valid 1" as "valid 2" } from "./type-clause-valid"; +export { type foo as "valid 3" } from "./type-clause-valid"; + +//// [type-clause-bad-import.ts] +import { type foo as "invalid 2" } from "./type-clause-valid"; + +//// [type-clause-bad-export.ts] export { type "invalid 3" as baz }; +//// [type-clause-no-as.ts] +import { type "invalid 1" } from "./type-clause-valid"; -//// [values.js] -// Valid +//// [type-clause-type-as-as.ts] +import { type as as "invalid 4" } from "./type-clause-valid"; + + +//// [values-valid.js] export const foo = 123; export { foo as "valid 1" }; -export { "valid 1" as "valid 2" } from "./values"; -export { foo as "valid 3" } from "./values"; -export * as "valid 4" from "./values"; +export { "valid 1" as "valid 2" } from "./values-valid"; +export { foo as "valid 3" } from "./values-valid"; +export * as "valid 4" from "./values-valid"; +//// [values-bad-import.js] +export {}; +//// [values-bad-export.js] export { "invalid 3" as baz }; -//// [types1.js] +//// [values-no-as.js] +export {}; +//// [values-type-as.js] export {}; -//// [types2.js] +//// [type-decls-valid.js] +export {}; +//// [type-decls-bad-import.js] +export {}; +//// [type-decls-bad-export.js] +export {}; +//// [type-decls-no-as.js] +export {}; +//// [type-decls-type-as.js] +export {}; +//// [type-clause-valid.js] +export {}; +//// [type-clause-bad-import.js] +export {}; +//// [type-clause-bad-export.js] +export {}; +//// [type-clause-no-as.js] +export {}; +//// [type-clause-type-as-as.js] export {}; -//// [values.d.ts] +//// [values-valid.d.ts] export declare const foo = 123; export { foo as "valid 1" }; -export { "valid 1" as "valid 2" } from "./values"; -export { foo as "valid 3" } from "./values"; -export * as "valid 4" from "./values"; +export { "valid 1" as "valid 2" } from "./values-valid"; +export { foo as "valid 3" } from "./values-valid"; +export * as "valid 4" from "./values-valid"; +//// [values-bad-import.d.ts] +export {}; +//// [values-bad-export.d.ts] export { "invalid 3" as baz }; -//// [types1.d.ts] +//// [values-no-as.d.ts] +export {}; +//// [values-type-as.d.ts] +export {}; +//// [type-decls-valid.d.ts] export type foo = 123; export type { foo as "valid 1" }; -export type { "valid 1" as "valid 2" } from "./types1"; -export type { foo as "valid 3" } from "./types1"; -export type * as "valid 4" from "./types1"; +export type { "valid 1" as "valid 2" } from "./type-decls-valid"; +export type { foo as "valid 3" } from "./type-decls-valid"; +export type * as "valid 4" from "./type-decls-valid"; +//// [type-decls-bad-import.d.ts] +export {}; +//// [type-decls-bad-export.d.ts] export type { "invalid 3" as baz }; -//// [types2.d.ts] +//// [type-decls-no-as.d.ts] +export {}; +//// [type-decls-type-as.d.ts] +export {}; +//// [type-clause-valid.d.ts] export type foo = 123; export { type foo as "valid 1" }; -export { type "valid 1" as "valid 2" } from "./types2"; -export { type foo as "valid 3" } from "./types2"; +export { type "valid 1" as "valid 2" } from "./type-clause-valid"; +export { type foo as "valid 3" } from "./type-clause-valid"; +//// [type-clause-bad-import.d.ts] +export {}; +//// [type-clause-bad-export.d.ts] export { type "invalid 3" as baz }; +//// [type-clause-no-as.d.ts] +export {}; +//// [type-clause-type-as-as.d.ts] +export {}; diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.symbols b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.symbols index 90c4adb5189d8..e1a127e15c91a 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.symbols +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.symbols @@ -1,98 +1,114 @@ //// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts] //// -=== values.ts === -// Valid +=== values-valid.ts === export const foo = 123; ->foo : Symbol(foo, Decl(values.ts, 1, 12)) +>foo : Symbol(foo, Decl(values-valid.ts, 0, 12)) export { foo as "valid 1" }; ->foo : Symbol(foo, Decl(values.ts, 1, 12)) ->"valid 1" : Symbol("valid 1", Decl(values.ts, 2, 8)) +>foo : Symbol(foo, Decl(values-valid.ts, 0, 12)) +>"valid 1" : Symbol("valid 1", Decl(values-valid.ts, 1, 8)) -import { "valid 1" as bar } from "./values"; ->bar : Symbol(bar, Decl(values.ts, 3, 8)) +import { "valid 1" as bar } from "./values-valid"; +>bar : Symbol(bar, Decl(values-valid.ts, 2, 8)) -export { "valid 1" as "valid 2" } from "./values"; ->"valid 2" : Symbol("valid 2", Decl(values.ts, 4, 8)) +export { "valid 1" as "valid 2" } from "./values-valid"; +>"valid 2" : Symbol("valid 2", Decl(values-valid.ts, 3, 8)) -export { foo as "valid 3" } from "./values"; ->foo : Symbol(foo, Decl(values.ts, 1, 12)) ->"valid 3" : Symbol("valid 3", Decl(values.ts, 5, 8)) +export { foo as "valid 3" } from "./values-valid"; +>foo : Symbol(foo, Decl(values-valid.ts, 0, 12)) +>"valid 3" : Symbol("valid 3", Decl(values-valid.ts, 4, 8)) -export * as "valid 4" from "./values"; ->"valid 4" : Symbol("valid 4", Decl(values.ts, 6, 6)) +export * as "valid 4" from "./values-valid"; +>"valid 4" : Symbol("valid 4", Decl(values-valid.ts, 5, 6)) -// Invalid -import { "invalid 1" } from "./values"; -> : Symbol((Missing), Decl(values.ts, 9, 8)) - -import { foo as "invalid 2" } from "./values"; ->foo : Symbol(foo, Decl(values.ts, 1, 12)) ->"invalid 2" : Symbol("invalid 2", Decl(values.ts, 10, 8)) +=== values-bad-import.ts === +import { foo as "invalid 2" } from "./values-valid"; +>foo : Symbol((Missing), Decl(values-valid.ts, 0, 12)) +> : Symbol((Missing), Decl(values-bad-import.ts, 0, 8)) +=== values-bad-export.ts === export { "invalid 3" as baz }; ->baz : Symbol(baz, Decl(values.ts, 11, 8)) +>baz : Symbol(baz, Decl(values-bad-export.ts, 0, 8)) + +=== values-no-as.ts === +import { "invalid 1" } from "./values-valid"; +> : Symbol((Missing), Decl(values-no-as.ts, 0, 8)) + +=== values-type-as.ts === +import { type as "invalid 4" } from "./values-valid"; +> : Symbol((Missing), Decl(values-type-as.ts, 0, 8)) -=== types1.ts === -// Valid + +=== type-decls-valid.ts === export type foo = 123; ->foo : Symbol(foo, Decl(types1.ts, 0, 0)) +>foo : Symbol(foo, Decl(type-decls-valid.ts, 0, 0)) export type { foo as "valid 1" }; ->foo : Symbol(foo, Decl(types1.ts, 0, 0)) ->"valid 1" : Symbol("valid 1", Decl(types1.ts, 2, 13)) - -import type { "valid 1" as bar } from "./types1"; ->bar : Symbol(bar, Decl(types1.ts, 3, 13)) +>foo : Symbol(foo, Decl(type-decls-valid.ts, 0, 0)) +>"valid 1" : Symbol("valid 1", Decl(type-decls-valid.ts, 1, 13)) -export type { "valid 1" as "valid 2" } from "./types1"; ->"valid 2" : Symbol("valid 2", Decl(types1.ts, 4, 13)) +import type { "valid 1" as bar } from "./type-decls-valid"; +>bar : Symbol(bar, Decl(type-decls-valid.ts, 2, 13)) -export type { foo as "valid 3" } from "./types1"; ->foo : Symbol(foo, Decl(types1.ts, 0, 0)) ->"valid 3" : Symbol("valid 3", Decl(types1.ts, 5, 13)) +export type { "valid 1" as "valid 2" } from "./type-decls-valid"; +>"valid 2" : Symbol("valid 2", Decl(type-decls-valid.ts, 3, 13)) -export type * as "valid 4" from "./types1"; ->"valid 4" : Symbol("valid 4", Decl(types1.ts, 6, 11)) +export type { foo as "valid 3" } from "./type-decls-valid"; +>foo : Symbol(foo, Decl(type-decls-valid.ts, 0, 0)) +>"valid 3" : Symbol("valid 3", Decl(type-decls-valid.ts, 4, 13)) -// Invalid -import type { "invalid 1" } from "./types1"; -> : Symbol((Missing), Decl(types1.ts, 9, 13)) +export type * as "valid 4" from "./type-decls-valid"; +>"valid 4" : Symbol("valid 4", Decl(type-decls-valid.ts, 5, 11)) -import type { foo as "invalid 2" } from "./types1"; ->foo : Symbol(foo, Decl(types1.ts, 0, 0)) ->"invalid 2" : Symbol("invalid 2", Decl(types1.ts, 10, 13)) +=== type-decls-bad-import.ts === +import type { foo as "invalid 2" } from "./type-decls-valid"; +>foo : Symbol((Missing), Decl(type-decls-valid.ts, 0, 0)) +> : Symbol((Missing), Decl(type-decls-bad-import.ts, 0, 13)) +=== type-decls-bad-export.ts === export type { "invalid 3" as baz }; ->baz : Symbol(baz, Decl(types1.ts, 11, 13)) +>baz : Symbol(baz, Decl(type-decls-bad-export.ts, 0, 13)) -=== types2.ts === -// Valid +=== type-decls-no-as.ts === +import type { "invalid 1" } from "./type-decls-valid"; +> : Symbol((Missing), Decl(type-decls-no-as.ts, 0, 13)) + +=== type-decls-type-as.ts === +import type { type as "invalid 4" } from "./type-decls-valid"; +> : Symbol((Missing), Decl(type-decls-type-as.ts, 0, 13)) + +=== type-clause-valid.ts === export type foo = 123; ->foo : Symbol(foo, Decl(types2.ts, 0, 0)) +>foo : Symbol(foo, Decl(type-clause-valid.ts, 0, 0)) export { type foo as "valid 1" }; ->foo : Symbol(foo, Decl(types2.ts, 0, 0)) ->"valid 1" : Symbol("valid 1", Decl(types2.ts, 2, 8)) - -import { type "valid 1" as bar } from "./types2"; ->bar : Symbol(bar, Decl(types2.ts, 3, 8)) +>foo : Symbol(foo, Decl(type-clause-valid.ts, 0, 0)) +>"valid 1" : Symbol("valid 1", Decl(type-clause-valid.ts, 1, 8)) -export { type "valid 1" as "valid 2" } from "./types2"; ->"valid 2" : Symbol("valid 2", Decl(types2.ts, 4, 8)) +import { type "valid 1" as bar } from "./type-clause-valid"; +>bar : Symbol(bar, Decl(type-clause-valid.ts, 2, 8)) -export { type foo as "valid 3" } from "./types2"; ->foo : Symbol(foo, Decl(types2.ts, 0, 0)) ->"valid 3" : Symbol("valid 3", Decl(types2.ts, 5, 8)) +export { type "valid 1" as "valid 2" } from "./type-clause-valid"; +>"valid 2" : Symbol("valid 2", Decl(type-clause-valid.ts, 3, 8)) -// Invalid -import { type "invalid 1" } from "./types2"; -> : Symbol((Missing), Decl(types2.ts, 8, 8)) +export { type foo as "valid 3" } from "./type-clause-valid"; +>foo : Symbol(foo, Decl(type-clause-valid.ts, 0, 0)) +>"valid 3" : Symbol("valid 3", Decl(type-clause-valid.ts, 4, 8)) -import { type foo as "invalid 2" } from "./types2"; ->foo : Symbol(foo, Decl(types2.ts, 0, 0)) ->"invalid 2" : Symbol("invalid 2", Decl(types2.ts, 9, 8)) +=== type-clause-bad-import.ts === +import { type foo as "invalid 2" } from "./type-clause-valid"; +>foo : Symbol((Missing), Decl(type-clause-valid.ts, 0, 0)) +> : Symbol((Missing), Decl(type-clause-bad-import.ts, 0, 8)) +=== type-clause-bad-export.ts === export { type "invalid 3" as baz }; ->baz : Symbol(baz, Decl(types2.ts, 10, 8)) +>baz : Symbol(baz, Decl(type-clause-bad-export.ts, 0, 8)) + +=== type-clause-no-as.ts === +import { type "invalid 1" } from "./type-clause-valid"; +> : Symbol((Missing), Decl(type-clause-no-as.ts, 0, 8)) + +=== type-clause-type-as-as.ts === +import { type as as "invalid 4" } from "./type-clause-valid"; +> : Symbol((Missing), Decl(type-clause-type-as-as.ts, 0, 8)) diff --git a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.types b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.types index ac11b2bfb067e..6129efe319ab1 100644 --- a/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.types +++ b/tests/baselines/reference/arbitraryModuleNamespaceIdentifiers_syntax.types @@ -1,7 +1,6 @@ //// [tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts] //// -=== values.ts === -// Valid +=== values-valid.ts === export const foo = 123; >foo : 123 > : ^^^ @@ -14,41 +13,50 @@ export { foo as "valid 1" }; >"valid 1" : 123 > : ^^^ -import { "valid 1" as bar } from "./values"; +import { "valid 1" as bar } from "./values-valid"; >bar : 123 > : ^^^ -export { "valid 1" as "valid 2" } from "./values"; +export { "valid 1" as "valid 2" } from "./values-valid"; >"valid 2" : 123 > : ^^^ -export { foo as "valid 3" } from "./values"; +export { foo as "valid 3" } from "./values-valid"; >foo : 123 > : ^^^ >"valid 3" : 123 > : ^^^ -export * as "valid 4" from "./values"; ->"valid 4" : typeof import("values") -> : ^^^^^^^^^^^^^^^^^^^^^^^ +export * as "valid 4" from "./values-valid"; +>"valid 4" : typeof import("values-valid") +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -// Invalid -import { "invalid 1" } from "./values"; -> : any -> : ^^^ - -import { foo as "invalid 2" } from "./values"; +=== values-bad-import.ts === +import { foo as "invalid 2" } from "./values-valid"; >foo : 123 > : ^^^ ->"invalid 2" : 123 -> : ^^^ +> : 123 +> : ^^^ +=== values-bad-export.ts === export { "invalid 3" as baz }; >baz : any > : ^^^ -=== types1.ts === -// Valid +=== values-no-as.ts === +import { "invalid 1" } from "./values-valid"; +> : any +> : ^^^ + +=== values-type-as.ts === +import { type as "invalid 4" } from "./values-valid"; +>type : any +> : ^^^ +> : any +> : ^^^ + + +=== type-decls-valid.ts === export type foo = 123; >foo : 123 > : ^^^ @@ -59,41 +67,49 @@ export type { foo as "valid 1" }; >"valid 1" : any > : ^^^ -import type { "valid 1" as bar } from "./types1"; +import type { "valid 1" as bar } from "./type-decls-valid"; >bar : 123 > : ^^^ -export type { "valid 1" as "valid 2" } from "./types1"; +export type { "valid 1" as "valid 2" } from "./type-decls-valid"; >"valid 2" : any > : ^^^ -export type { foo as "valid 3" } from "./types1"; +export type { foo as "valid 3" } from "./type-decls-valid"; >foo : any > : ^^^ >"valid 3" : any > : ^^^ -export type * as "valid 4" from "./types1"; ->"valid 4" : typeof import("types1") -> : ^^^^^^^^^^^^^^^^^^^^^^^ - -// Invalid -import type { "invalid 1" } from "./types1"; -> : any -> : ^^^ +export type * as "valid 4" from "./type-decls-valid"; +>"valid 4" : typeof import("type-decls-valid") +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -import type { foo as "invalid 2" } from "./types1"; +=== type-decls-bad-import.ts === +import type { foo as "invalid 2" } from "./type-decls-valid"; >foo : any > : ^^^ ->"invalid 2" : any -> : ^^^ +> : 123 +> : ^^^ +=== type-decls-bad-export.ts === export type { "invalid 3" as baz }; >baz : any > : ^^^ -=== types2.ts === -// Valid +=== type-decls-no-as.ts === +import type { "invalid 1" } from "./type-decls-valid"; +> : any +> : ^^^ + +=== type-decls-type-as.ts === +import type { type as "invalid 4" } from "./type-decls-valid"; +>type : any +> : ^^^ +> : any +> : ^^^ + +=== type-clause-valid.ts === export type foo = 123; >foo : 123 > : ^^^ @@ -104,32 +120,41 @@ export { type foo as "valid 1" }; >"valid 1" : any > : ^^^ -import { type "valid 1" as bar } from "./types2"; +import { type "valid 1" as bar } from "./type-clause-valid"; >bar : any > : ^^^ -export { type "valid 1" as "valid 2" } from "./types2"; +export { type "valid 1" as "valid 2" } from "./type-clause-valid"; >"valid 2" : any > : ^^^ -export { type foo as "valid 3" } from "./types2"; +export { type foo as "valid 3" } from "./type-clause-valid"; >foo : any > : ^^^ >"valid 3" : any > : ^^^ -// Invalid -import { type "invalid 1" } from "./types2"; -> : any -> : ^^^ - -import { type foo as "invalid 2" } from "./types2"; +=== type-clause-bad-import.ts === +import { type foo as "invalid 2" } from "./type-clause-valid"; >foo : any > : ^^^ ->"invalid 2" : any -> : ^^^ +> : any +> : ^^^ +=== type-clause-bad-export.ts === export { type "invalid 3" as baz }; >baz : any > : ^^^ +=== type-clause-no-as.ts === +import { type "invalid 1" } from "./type-clause-valid"; +> : any +> : ^^^ + +=== type-clause-type-as-as.ts === +import { type as as "invalid 4" } from "./type-clause-valid"; +>as : any +> : ^^^ +> : any +> : ^^^ + diff --git a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts index 0c8e3f84c216e..d4bb2ffd3a328 100644 --- a/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts +++ b/tests/cases/conformance/es2022/arbitraryModuleNamespaceIdentifiers/arbitraryModuleNamespaceIdentifiers_syntax.ts @@ -2,46 +2,63 @@ //@target: ES2022 //@declaration: true -// @filename: values.ts -// Valid +// @filename: values-valid.ts export const foo = 123; export { foo as "valid 1" }; -import { "valid 1" as bar } from "./values"; -export { "valid 1" as "valid 2" } from "./values"; -export { foo as "valid 3" } from "./values"; -export * as "valid 4" from "./values"; - -// Invalid -import { "invalid 1" } from "./values"; -import { foo as "invalid 2" } from "./values"; +import { "valid 1" as bar } from "./values-valid"; +export { "valid 1" as "valid 2" } from "./values-valid"; +export { foo as "valid 3" } from "./values-valid"; +export * as "valid 4" from "./values-valid"; + +// @filename: values-bad-import.ts +import { foo as "invalid 2" } from "./values-valid"; + +// @filename: values-bad-export.ts export { "invalid 3" as baz }; -// @filename: types1.ts +// @filename: values-no-as.ts +import { "invalid 1" } from "./values-valid"; + +// @filename: values-type-as.ts +import { type as "invalid 4" } from "./values-valid"; -// Valid + +// @filename: type-decls-valid.ts export type foo = 123; export type { foo as "valid 1" }; -import type { "valid 1" as bar } from "./types1"; -export type { "valid 1" as "valid 2" } from "./types1"; -export type { foo as "valid 3" } from "./types1"; -export type * as "valid 4" from "./types1"; - -// Invalid -import type { "invalid 1" } from "./types1"; -import type { foo as "invalid 2" } from "./types1"; +import type { "valid 1" as bar } from "./type-decls-valid"; +export type { "valid 1" as "valid 2" } from "./type-decls-valid"; +export type { foo as "valid 3" } from "./type-decls-valid"; +export type * as "valid 4" from "./type-decls-valid"; + +// @filename: type-decls-bad-import.ts +import type { foo as "invalid 2" } from "./type-decls-valid"; + +// @filename: type-decls-bad-export.ts export type { "invalid 3" as baz }; -// @filename: types2.ts +// @filename: type-decls-no-as.ts +import type { "invalid 1" } from "./type-decls-valid"; + +// @filename: type-decls-type-as.ts +import type { type as "invalid 4" } from "./type-decls-valid"; -// Valid +// @filename: type-clause-valid.ts export type foo = 123; export { type foo as "valid 1" }; -import { type "valid 1" as bar } from "./types2"; -export { type "valid 1" as "valid 2" } from "./types2"; -export { type foo as "valid 3" } from "./types2"; +import { type "valid 1" as bar } from "./type-clause-valid"; +export { type "valid 1" as "valid 2" } from "./type-clause-valid"; +export { type foo as "valid 3" } from "./type-clause-valid"; + +// @filename: type-clause-bad-import.ts +import { type foo as "invalid 2" } from "./type-clause-valid"; -// Invalid -import { type "invalid 1" } from "./types2"; -import { type foo as "invalid 2" } from "./types2"; +// @filename: type-clause-bad-export.ts export { type "invalid 3" as baz }; + +// @filename: type-clause-no-as.ts +import { type "invalid 1" } from "./type-clause-valid"; + +// @filename: type-clause-type-as-as.ts +import { type as as "invalid 4" } from "./type-clause-valid"; From 627fa896490bc2dd2400e4e23472139af2db6786 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Thu, 30 May 2024 01:07:21 -0400 Subject: [PATCH 11/11] run `lint --fix` (removed spaces from a comment) --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1adafde468dd0..3cb942dfad62e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -8618,7 +8618,7 @@ namespace Parser { if (name.kind !== SyntaxKind.Identifier) { // ImportSpecifier casts "name" to Identifier below, so make sure it's an identifier parseErrorAt(skipTrivia(sourceText, name.pos), name.end, Diagnostics.Identifier_expected); - name = setTextRangePosEnd(createMissingNode(SyntaxKind.Identifier, /* reportAtCurrentPosition */ false), name.pos, name.pos); + name = setTextRangePosEnd(createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false), name.pos, name.pos); } else if (checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected);