From 8aa9c3b4d95232cb955cba3774a01bcd7bec2bb0 Mon Sep 17 00:00:00 2001 From: Jack Works Date: Wed, 14 Jun 2023 00:18:48 +0800 Subject: [PATCH 1/6] Improve error for unclosed imports and exports fix: error --- src/compiler/parser.ts | 14 +++++- .../unclosedExportClause01.errors.txt | 35 ++++---------- .../reference/unclosedExportClause01.js | 12 ++--- .../reference/unclosedExportClause01.symbols | 5 +- .../reference/unclosedExportClause01.types | 5 +- .../unclosedExportClause02.errors.txt | 46 +++++-------------- .../reference/unclosedExportClause02.js | 17 +++---- .../reference/unclosedExportClause02.symbols | 8 ++-- .../reference/unclosedExportClause02.types | 21 +++------ 9 files changed, 57 insertions(+), 106 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f49b48bb44295..eb2da7e8fc344 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2869,6 +2869,11 @@ namespace Parser { case ParsingContext.HeritageClauses: return isHeritageClause(); case ParsingContext.ImportOrExportSpecifiers: + // bail out if the next token is [FromKeyword StringLiteral]. + // That means we're in something like `import { from "mod"`. Stop here can give better error message. + if (token() === SyntaxKind.FromKeyword && lookAhead(nextTokenIsStringLiteral)) { + return false; + } return tokenIsIdentifierOrKeyword(token()); case ParsingContext.JsxAttributes: return tokenIsIdentifierOrKeyword(token()) || token() === SyntaxKind.OpenBraceToken; @@ -3390,7 +3395,11 @@ namespace Parser { case ParsingContext.TypeArguments: return parseErrorAtCurrentToken(Diagnostics.Type_argument_expected); case ParsingContext.TupleElementTypes: return parseErrorAtCurrentToken(Diagnostics.Type_expected); case ParsingContext.HeritageClauses: return parseErrorAtCurrentToken(Diagnostics.Unexpected_token_expected); - case ParsingContext.ImportOrExportSpecifiers: return parseErrorAtCurrentToken(Diagnostics.Identifier_expected); + case ParsingContext.ImportOrExportSpecifiers: + if (token() === SyntaxKind.FromKeyword) { + return parseErrorAtCurrentToken(Diagnostics._0_expected, "}"); + } + return parseErrorAtCurrentToken(Diagnostics.Identifier_expected); case ParsingContext.JsxAttributes: return parseErrorAtCurrentToken(Diagnostics.Identifier_expected); case ParsingContext.JsxChildren: return parseErrorAtCurrentToken(Diagnostics.Identifier_expected); case ParsingContext.AssertEntries: return parseErrorAtCurrentToken(Diagnostics.Identifier_or_string_literal_expected); // AssertionKey. @@ -7358,6 +7367,9 @@ namespace Parser { } } + function nextTokenIsStringLiteral() { + return nextToken() === SyntaxKind.StringLiteral; + } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === SyntaxKind.StringLiteral); diff --git a/tests/baselines/reference/unclosedExportClause01.errors.txt b/tests/baselines/reference/unclosedExportClause01.errors.txt index ec3ef3cf322f0..825ad6a1b3c81 100644 --- a/tests/baselines/reference/unclosedExportClause01.errors.txt +++ b/tests/baselines/reference/unclosedExportClause01.errors.txt @@ -1,43 +1,28 @@ -t2.ts(1,13): error TS2305: Module '"./t1"' has no exported member 'from'. -t2.ts(1,18): error TS1005: ',' expected. -t3.ts(1,10): error TS2305: Module '"./t1"' has no exported member 'from'. -t3.ts(1,15): error TS1005: ',' expected. +t2.ts(1,13): error TS1005: '}' expected. +t3.ts(1,10): error TS1005: '}' expected. t4.ts(1,17): error TS1005: ',' expected. -t4.ts(1,17): error TS2305: Module '"./t1"' has no exported member 'from'. -t4.ts(1,22): error TS1005: ',' expected. -t5.ts(1,18): error TS2305: Module '"./t1"' has no exported member 'from'. -t5.ts(1,23): error TS1005: ',' expected. +t5.ts(1,18): error TS1005: '}' expected. ==== t1.ts (0 errors) ==== export var x = "x"; -==== t2.ts (2 errors) ==== +==== t2.ts (1 errors) ==== export { x, from "./t1" ~~~~ -!!! error TS2305: Module '"./t1"' has no exported member 'from'. - ~~~~~~ -!!! error TS1005: ',' expected. +!!! error TS1005: '}' expected. -==== t3.ts (2 errors) ==== +==== t3.ts (1 errors) ==== export { from "./t1" ~~~~ -!!! error TS2305: Module '"./t1"' has no exported member 'from'. - ~~~~~~ -!!! error TS1005: ',' expected. +!!! error TS1005: '}' expected. -==== t4.ts (3 errors) ==== +==== t4.ts (1 errors) ==== export { x as a from "./t1" ~~~~ !!! error TS1005: ',' expected. - ~~~~ -!!! error TS2305: Module '"./t1"' has no exported member 'from'. - ~~~~~~ -!!! error TS1005: ',' expected. -==== t5.ts (2 errors) ==== +==== t5.ts (1 errors) ==== export { x as a, from "./t1" ~~~~ -!!! error TS2305: Module '"./t1"' has no exported member 'from'. - ~~~~~~ -!!! error TS1005: ',' expected. \ No newline at end of file +!!! error TS1005: '}' expected. \ No newline at end of file diff --git a/tests/baselines/reference/unclosedExportClause01.js b/tests/baselines/reference/unclosedExportClause01.js index ef0d2a5be634c..a7b46515a687d 100644 --- a/tests/baselines/reference/unclosedExportClause01.js +++ b/tests/baselines/reference/unclosedExportClause01.js @@ -23,27 +23,21 @@ exports.x = "x"; //// [t2.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.from = exports.x = void 0; +exports.x = void 0; var t1_1 = require("./t1"); Object.defineProperty(exports, "x", { enumerable: true, get: function () { return t1_1.x; } }); -Object.defineProperty(exports, "from", { enumerable: true, get: function () { return t1_1.from; } }); //// [t3.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.from = void 0; -var t1_1 = require("./t1"); -Object.defineProperty(exports, "from", { enumerable: true, get: function () { return t1_1.from; } }); //// [t4.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.from = exports.a = void 0; +exports.a = void 0; var t1_1 = require("./t1"); Object.defineProperty(exports, "a", { enumerable: true, get: function () { return t1_1.x; } }); -Object.defineProperty(exports, "from", { enumerable: true, get: function () { return t1_1.from; } }); //// [t5.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.from = exports.a = void 0; +exports.a = void 0; var t1_1 = require("./t1"); Object.defineProperty(exports, "a", { enumerable: true, get: function () { return t1_1.x; } }); -Object.defineProperty(exports, "from", { enumerable: true, get: function () { return t1_1.from; } }); diff --git a/tests/baselines/reference/unclosedExportClause01.symbols b/tests/baselines/reference/unclosedExportClause01.symbols index 65cfcc297adc8..9b7f85697b97b 100644 --- a/tests/baselines/reference/unclosedExportClause01.symbols +++ b/tests/baselines/reference/unclosedExportClause01.symbols @@ -7,21 +7,18 @@ export var x = "x"; === t2.ts === export { x, from "./t1" >x : Symbol(x, Decl(t2.ts, 0, 8)) ->from : Symbol(from, Decl(t2.ts, 0, 11)) === t3.ts === + export { from "./t1" ->from : Symbol(from, Decl(t3.ts, 0, 8)) === t4.ts === export { x as a from "./t1" >x : Symbol(x, Decl(t1.ts, 0, 10)) >a : Symbol(a, Decl(t4.ts, 0, 8)) ->from : Symbol(from, Decl(t4.ts, 0, 15)) === t5.ts === export { x as a, from "./t1" >x : Symbol(x, Decl(t1.ts, 0, 10)) >a : Symbol(a, Decl(t5.ts, 0, 8)) ->from : Symbol(from, Decl(t5.ts, 0, 16)) diff --git a/tests/baselines/reference/unclosedExportClause01.types b/tests/baselines/reference/unclosedExportClause01.types index b9a286a5ab49f..a4b897f9091b0 100644 --- a/tests/baselines/reference/unclosedExportClause01.types +++ b/tests/baselines/reference/unclosedExportClause01.types @@ -8,21 +8,18 @@ export var x = "x"; === t2.ts === export { x, from "./t1" >x : string ->from : any === t3.ts === + export { from "./t1" ->from : any === t4.ts === export { x as a from "./t1" >x : string >a : string ->from : any === t5.ts === export { x as a, from "./t1" >x : string >a : string ->from : any diff --git a/tests/baselines/reference/unclosedExportClause02.errors.txt b/tests/baselines/reference/unclosedExportClause02.errors.txt index 930ebdc40a0e6..2f1978e46bc39 100644 --- a/tests/baselines/reference/unclosedExportClause02.errors.txt +++ b/tests/baselines/reference/unclosedExportClause02.errors.txt @@ -1,56 +1,32 @@ -t2.ts(1,10): error TS2304: Cannot find name 'x'. -t2.ts(1,13): error TS2304: Cannot find name 'from'. -t2.ts(2,5): error TS1005: ',' expected. -t3.ts(1,10): error TS2304: Cannot find name 'from'. -t3.ts(2,5): error TS1005: ',' expected. -t4.ts(1,10): error TS2304: Cannot find name 'x'. +t2.ts(1,13): error TS1005: '}' expected. +t3.ts(1,10): error TS1005: '}' expected. t4.ts(1,17): error TS1005: ',' expected. -t4.ts(1,17): error TS2304: Cannot find name 'from'. -t4.ts(2,5): error TS1005: ',' expected. -t5.ts(1,10): error TS2304: Cannot find name 'x'. -t5.ts(1,18): error TS2304: Cannot find name 'from'. -t5.ts(2,5): error TS1005: ',' expected. +t5.ts(1,18): error TS1005: '}' expected. ==== t1.ts (0 errors) ==== export var x = "x"; -==== t2.ts (3 errors) ==== +==== t2.ts (1 errors) ==== export { x, from - ~ -!!! error TS2304: Cannot find name 'x'. ~~~~ -!!! error TS2304: Cannot find name 'from'. +!!! error TS1005: '}' expected. "./t1"; - ~~~~~~ -!!! error TS1005: ',' expected. -==== t3.ts (2 errors) ==== +==== t3.ts (1 errors) ==== export { from ~~~~ -!!! error TS2304: Cannot find name 'from'. +!!! error TS1005: '}' expected. "./t1"; - ~~~~~~ -!!! error TS1005: ',' expected. -==== t4.ts (4 errors) ==== +==== t4.ts (1 errors) ==== export { x as a from - ~ -!!! error TS2304: Cannot find name 'x'. ~~~~ !!! error TS1005: ',' expected. - ~~~~ -!!! error TS2304: Cannot find name 'from'. "./t1"; - ~~~~~~ -!!! error TS1005: ',' expected. -==== t5.ts (3 errors) ==== +==== t5.ts (1 errors) ==== export { x as a, from - ~ -!!! error TS2304: Cannot find name 'x'. ~~~~ -!!! error TS2304: Cannot find name 'from'. - "./t1"; - ~~~~~~ -!!! error TS1005: ',' expected. \ No newline at end of file +!!! error TS1005: '}' expected. + "./t1"; \ No newline at end of file diff --git a/tests/baselines/reference/unclosedExportClause02.js b/tests/baselines/reference/unclosedExportClause02.js index d553c74911d5f..3403afdac989e 100644 --- a/tests/baselines/reference/unclosedExportClause02.js +++ b/tests/baselines/reference/unclosedExportClause02.js @@ -27,20 +27,21 @@ exports.x = "x"; //// [t2.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.from = exports.x = void 0; -"./t1"; +exports.x = void 0; +var t1_1 = require("./t1"); +Object.defineProperty(exports, "x", { enumerable: true, get: function () { return t1_1.x; } }); //// [t3.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.from = void 0; -"./t1"; //// [t4.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.from = exports.a = void 0; -"./t1"; +exports.a = void 0; +var t1_1 = require("./t1"); +Object.defineProperty(exports, "a", { enumerable: true, get: function () { return t1_1.x; } }); //// [t5.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.from = exports.a = void 0; -"./t1"; +exports.a = void 0; +var t1_1 = require("./t1"); +Object.defineProperty(exports, "a", { enumerable: true, get: function () { return t1_1.x; } }); diff --git a/tests/baselines/reference/unclosedExportClause02.symbols b/tests/baselines/reference/unclosedExportClause02.symbols index fa45dc4a5f2b8..a528768936790 100644 --- a/tests/baselines/reference/unclosedExportClause02.symbols +++ b/tests/baselines/reference/unclosedExportClause02.symbols @@ -7,26 +7,24 @@ export var x = "x"; === t2.ts === export { x, from >x : Symbol(x, Decl(t2.ts, 0, 8)) ->from : Symbol(from, Decl(t2.ts, 0, 11)) "./t1"; === t3.ts === -export { from ->from : Symbol(from, Decl(t3.ts, 0, 8)) +export { from "./t1"; === t4.ts === export { x as a from +>x : Symbol(x, Decl(t1.ts, 0, 10)) >a : Symbol(a, Decl(t4.ts, 0, 8)) ->from : Symbol(from, Decl(t4.ts, 0, 15)) "./t1"; === t5.ts === export { x as a, from +>x : Symbol(x, Decl(t1.ts, 0, 10)) >a : Symbol(a, Decl(t5.ts, 0, 8)) ->from : Symbol(from, Decl(t5.ts, 0, 16)) "./t1"; diff --git a/tests/baselines/reference/unclosedExportClause02.types b/tests/baselines/reference/unclosedExportClause02.types index 0ddbdbbc6db77..9588153e06c53 100644 --- a/tests/baselines/reference/unclosedExportClause02.types +++ b/tests/baselines/reference/unclosedExportClause02.types @@ -7,34 +7,25 @@ export var x = "x"; === t2.ts === export { x, from ->x : any ->from : any +>x : string "./t1"; ->"./t1" : "./t1" === t3.ts === -export { from ->from : any +export { from "./t1"; ->"./t1" : "./t1" === t4.ts === export { x as a from ->x : any ->a : any ->from : any +>x : string +>a : string "./t1"; ->"./t1" : "./t1" === t5.ts === export { x as a, from ->x : any ->a : any ->from : any +>x : string +>a : string "./t1"; ->"./t1" : "./t1" - From 2435a738f68027264faf7471d70e28a736db53f9 Mon Sep 17 00:00:00 2001 From: Jack Works Date: Wed, 14 Jun 2023 00:12:39 +0800 Subject: [PATCH 2/6] Normative: Arbitrary module namespace identifier names --- src/compiler/binder.ts | 6 +- src/compiler/checker.ts | 148 ++++++++++++------ src/compiler/diagnosticMessages.json | 8 + src/compiler/factory/nodeFactory.ts | 27 +++- src/compiler/factory/nodeTests.ts | 5 + src/compiler/factory/utilities.ts | 8 +- src/compiler/parser.ts | 60 +++++-- src/compiler/transformers/declarations.ts | 3 +- .../transformers/module/esnextAnd2015.ts | 130 ++++++++++++++- src/compiler/transformers/module/module.ts | 26 +-- src/compiler/transformers/module/system.ts | 17 +- src/compiler/transformers/utilities.ts | 33 ++-- src/compiler/types.ts | 27 ++-- src/compiler/utilities.ts | 30 +++- src/compiler/utilitiesPublic.ts | 4 +- src/compiler/visitorPublic.ts | 9 +- src/services/codefixes/convertToEsModule.ts | 4 +- .../codefixes/fixInvalidImportSyntax.ts | 3 +- src/services/completions.ts | 29 +++- src/services/findAllReferences.ts | 16 +- src/services/goToDefinition.ts | 5 + src/services/importTracker.ts | 16 +- src/services/organizeImports.ts | 3 +- src/services/refactors/convertExport.ts | 5 +- src/testRunner/unittests/transform.ts | 3 +- .../reference/api/tsserverlibrary.d.ts | 28 ++-- tests/baselines/reference/api/typescript.d.ts | 28 ++-- ...ToDefinitionImportedNames12.baseline.jsonc | 103 ++++++++++++ .../goToDefinitionImportedNames12.ts | 24 +++ 29 files changed, 635 insertions(+), 173 deletions(-) create mode 100644 tests/baselines/reference/goToDefinitionImportedNames12.baseline.jsonc create mode 100644 tests/cases/fourslash/goToDefinitionImportedNames12.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index f54a3e0666f00..4eb2b2ad6e347 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -243,6 +243,8 @@ import { ModifierFlags, ModuleBlock, ModuleDeclaration, + moduleExportNameText, + moduleExportNameTextEscaped, Mutable, NamespaceExportDeclaration, Node, @@ -432,7 +434,7 @@ function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visite const statements = p.statements; let found: ModuleInstanceState | undefined; for (const statement of statements) { - if (nodeHasName(statement, name)) { + if (nodeHasName(statement, moduleExportNameText(name))) { if (!statement.parent) { setParent(statement, p); setParentRecursive(statement, /*incremental*/ false); @@ -738,7 +740,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) && moduleExportNameTextEscaped(node.name) === "default"; // 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 967ad86941b40..f1b6b117dd859 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -623,6 +623,7 @@ import { isModifier, isModuleBlock, isModuleDeclaration, + isModuleExportName, isModuleExportsAccessExpression, isModuleIdentifier, isModuleOrEnumDeclaration, @@ -826,6 +827,9 @@ import { modifierToFlag, ModuleBlock, ModuleDeclaration, + ModuleExportName, + moduleExportNameText, + moduleExportNameTextEscaped, ModuleInstanceState, ModuleKind, ModuleResolutionKind, @@ -3329,7 +3333,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (lastLocation && lastLocation === (location as ExportSpecifier).propertyName && (location as ExportSpecifier).parent.parent.moduleSpecifier) { - location = location.parent.parent.parent; + // skip to to parent ModuleBlock or SourceFile. + location = (location as ExportSpecifier).parent.parent.parent; } break; } @@ -3916,7 +3921,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 ? "*" : moduleExportNameText(typeOnlyDeclaration.name); addRelatedInfo(error(node.moduleReference, message), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name)); } } @@ -4128,12 +4133,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return result; } - function getExportOfModule(symbol: Symbol, name: Identifier, specifier: Declaration, dontResolveAlias: boolean): Symbol | undefined { + function getExportOfModule(symbol: Symbol, name: ModuleExportName, specifier: Declaration, dontResolveAlias: boolean): Symbol | undefined { if (symbol.flags & SymbolFlags.Module) { - const exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); + const escapedName = moduleExportNameTextEscaped(name); + const exportSymbol = getExportsOfSymbol(symbol).get(escapedName); 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(escapedName); + markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false, exportStarDeclaration, escapedName); return resolved; } } @@ -4151,13 +4157,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const moduleSpecifier = getExternalModuleRequireArgument(node) || (node as ImportDeclaration | ExportDeclaration).moduleSpecifier!; const moduleSymbol = resolveExternalModuleName(node, moduleSpecifier)!; // TODO: GH#18217 const name = !isPropertyAccessExpression(specifier) && specifier.propertyName || specifier.name; - if (!isIdentifier(name)) { + if (!isModuleExportName(name)) { return undefined; } - const suppressInteropError = name.escapedText === InternalSymbolName.Default && allowSyntheticDefaultImports; + const escapedName = moduleExportNameTextEscaped(name); + const suppressInteropError = escapedName === InternalSymbolName.Default && allowSyntheticDefaultImports; const targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { - if (name.escapedText) { + if (escapedName) { if (isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } @@ -4165,16 +4172,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), escapedName, /*skipObjectFunctionPropertyAugment*/ true); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText); + symbolFromVariable = getPropertyOfVariable(targetSymbol, escapedName); } // 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) { + if (symbolFromModule === undefined && escapedName === InternalSymbolName.Default) { const file = moduleSymbol.declarations?.find(isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -4192,7 +4199,7 @@ 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); @@ -4220,8 +4227,11 @@ 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 { + // for import { "ident" as T } we can provide meaningful error message. (ident is defined locally) + // for import { "not ident" as T } we will still look for the locals of the target module symbol, but + // since it's impossible to define a local ident with invalid name, we will use the normal message "Module_0_has_no_exported_member_1" + const localSymbol = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)?.locals?.get(moduleExportNameTextEscaped(name)); const exports = moduleSymbol.exports; if (localSymbol) { const exportedEqualsSymbol = exports?.get(InternalSymbolName.ExportEquals); @@ -4245,7 +4255,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; @@ -4266,7 +4276,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) && moduleExportNameText(node.propertyName || node.name) === InternalSymbolName.Default) { const specifier = getModuleSpecifierForImportOrExport(node); const moduleSymbol = specifier && resolveExternalModuleName(node, specifier); if (moduleSymbol) { @@ -4299,16 +4309,22 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getTargetOfExportSpecifier(node: ExportSpecifier, meaning: SymbolFlags, dontResolveAlias?: boolean) { - if (idText(node.propertyName || node.name) === InternalSymbolName.Default) { + if (moduleExportNameText(node.propertyName || node.name) === InternalSymbolName.Default) { const specifier = getModuleSpecifierForImportOrExport(node); const moduleSymbol = specifier && resolveExternalModuleName(node, specifier); if (moduleSymbol) { return getTargetofModuleDefault(moduleSymbol, node, !!dontResolveAlias); } } - const resolved = node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : - resolveEntityName(node.propertyName || node.name, meaning, /*ignoreErrors*/ false, dontResolveAlias); + const exported = node.propertyName || node.name; + let resolved: Symbol | undefined; + if (node.parent.parent.moduleSpecifier) { + resolved = getExternalModuleMember(node.parent.parent, node, dontResolveAlias); + } + // skip resolution for grammar error export { "x" } + else if (exported.kind !== SyntaxKind.StringLiteral) { + resolved = resolveEntityName(exported, meaning, /*ignoreErrors*/ false, dontResolveAlias); + } markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false); return resolved; } @@ -8508,7 +8524,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!e.propertyName) { // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it const indices = indicesOf(statements); - const associatedIndices = filter(indices, i => nodeHasName(statements[i], e.name)); + const associatedIndices = filter(indices, i => { + if (e.name.kind === SyntaxKind.StringLiteral) return false; + return nodeHasName(statements[i], e.name); + }); if (length(associatedIndices) && every(associatedIndices, i => canHaveExportModifier(statements[i]))) { for (const index of associatedIndices) { statements[index] = addExportModifier(statements[index] as Extract); @@ -8688,7 +8707,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { factory.createExportDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, - factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)]) + factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, alias, factory.createModuleExportName(localName, languageVersion))]) ), ModifierFlags.None ); @@ -8725,7 +8744,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { factory.createExportDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, - factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)]) + factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, factory.createModuleExportName(name, languageVersion), factory.createModuleExportName(localName, languageVersion))]) ), ModifierFlags.None ); @@ -8784,7 +8803,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { addResult(factory.createExportDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, - factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)]) + factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, factory.createModuleExportName(getInternalSymbolName(symbol, symbolName), languageVersion), factory.createModuleExportName(symbolName, languageVersion))]) ), ModifierFlags.None); } } @@ -8922,7 +8941,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); includePrivateSymbol(target || s); const targetName = target ? getInternalSymbolName(target, unescapeLeadingUnderscores(target.escapedName)) : localName; - return factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name); + return factory.createExportSpecifier(/*isTypeOnly*/ false, factory.createModuleExportName(name === targetName ? undefined : targetName, languageVersion), factory.createModuleExportName(name, languageVersion)); })) )]); addResult(factory.createModuleDeclaration( @@ -9150,7 +9169,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 moduleExportNameText(d.propertyName || d.name); } if (isBinaryExpression(d) || isExportAssignment(d)) { const expression = isExportAssignment(d) ? d.expression : d.right; @@ -9354,7 +9373,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { addResult(factory.createExportDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, - factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), + factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, factory.createModuleExportName(localName !== targetName ? targetName : undefined, languageVersion), factory.createModuleExportName(localName, languageVersion))]), specifier ), ModifierFlags.None); } @@ -10011,9 +10030,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.parent?.kind === SyntaxKind.ExportAssignment && node.kind !== SyntaxKind.StringLiteral) { exportSymbol = resolveName(node, node.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } else if (node.parent.kind === SyntaxKind.ExportSpecifier) { @@ -31919,8 +31938,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return symbolResult && symbolName(symbolResult); } - function getSuggestedSymbolForNonexistentModule(name: Identifier, targetModule: Symbol): Symbol | undefined { - return targetModule.exports && getSpellingSuggestionForName(idText(name), getExportsOfModuleAsArray(targetModule), SymbolFlags.ModuleMember); + function getSuggestedSymbolForNonexistentModule(name: ModuleExportName, targetModule: Symbol): Symbol | undefined { + return targetModule.exports && getSpellingSuggestionForName(moduleExportNameText(name), getExportsOfModuleAsArray(targetModule), SymbolFlags.ModuleMember); } function getSuggestionForNonexistentExport(name: Identifier, targetModule: Symbol): string | undefined { @@ -44143,7 +44162,8 @@ 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 exported = node.propertyName || node.name; + const alreadyExportedSymbol = getSourceFileOfNode(node).symbol?.exports?.get(moduleExportNameTextEscaped(exported)); if (alreadyExportedSymbol === target) { const exportingDeclaration = alreadyExportedSymbol.declarations?.find(isJSDocNode); if (exportingDeclaration) { @@ -44201,7 +44221,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { : compilerOptions.verbatimModuleSyntax ? Diagnostics._0_resolves_to_a_type_only_declaration_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_preserveValueImports_and_isolatedModules_are_both_enabled; - const name = idText(node.kind === SyntaxKind.ImportSpecifier ? node.propertyName || node.name : node.name); + const name = moduleExportNameText(node.kind === SyntaxKind.ImportSpecifier ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo( error(node, message, name), isType ? undefined : typeOnlyAlias, @@ -44218,7 +44238,9 @@ 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 exported = node.propertyName || node.name; + const name = moduleExportNameText(exported); 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); @@ -44281,7 +44303,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); if (node.kind === SyntaxKind.ImportSpecifier && - idText(node.propertyName || node.name) === "default" && + moduleExportNameText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) { checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault); @@ -44452,8 +44474,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function checkGrammarExportDeclaration(node: ExportDeclaration): boolean { - if (node.isTypeOnly && node.exportClause?.kind === SyntaxKind.NamedExports) { - return checkGrammarNamedImportsOrExports(node.exportClause); + if (node.exportClause?.kind === SyntaxKind.NamedExports) { + return checkGrammarNamedImportsOrExports(node.exportClause, node.isTypeOnly, !node.moduleSpecifier); + } + if ( + (moduleKind === ModuleKind.ES2015 || moduleKind === ModuleKind.ES2020) && + node.exportClause?.kind === SyntaxKind.NamespaceExport && + node.exportClause.name.kind === SyntaxKind.StringLiteral && + !isIdentifierText(node.exportClause.name.text, languageVersion) + ) { + grammarErrorOnNode(node.exportClause.name, Diagnostics.String_literal_module_export_names_are_not_allowed_when_the_module_option_is_set_to_es2020_or_lower); + return true; } return false; } @@ -44516,6 +44547,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (!node.parent.parent.moduleSpecifier) { const exportedName = node.propertyName || node.name; + if (exportedName.kind === SyntaxKind.StringLiteral) { + // export { "x" } or export { "x" as name } is a syntax error. reported in grammar check. + return; + } // 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, /*nameArg*/ undefined, /*isUse*/ true); @@ -44536,7 +44571,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (getESModuleInterop(compilerOptions) && moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS) && - idText(node.propertyName || node.name) === "default") { + moduleExportNameText(node.propertyName || node.name) === "default") { checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault); } } @@ -45835,9 +45870,13 @@ 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)) { - return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); + if (node.parent.parent.moduleSpecifier) { + return getExternalModuleMember(node.parent.parent, node); + } + const exported = node.propertyName || node.name; + // skip resolution for grammar error export { "" as X }. + if (exported.kind === SyntaxKind.StringLiteral) return undefined; + return resolveEntityName(exported, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } else { return resolveEntityName(node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); @@ -48818,21 +48857,36 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && node.namedBindings?.kind === SyntaxKind.NamedImports) { - return checkGrammarNamedImportsOrExports(node.namedBindings); + if (node.namedBindings?.kind === SyntaxKind.NamedImports) { + return checkGrammarNamedImportsOrExports(node.namedBindings, node.isTypeOnly, /*isExportLocal*/ false); } return false; } - function checkGrammarNamedImportsOrExports(namedBindings: NamedImportsOrExports): boolean { + function checkGrammarNamedImportsOrExports(namedBindings: NamedImportsOrExports, isTypeOnly: boolean, isExportLocal: boolean): boolean { + const checkString = moduleKind === ModuleKind.ES2015 || moduleKind === ModuleKind.ES2020; + if (!isTypeOnly && !isExportLocal && !checkString) return false; return !!forEach(namedBindings.elements, specifier => { - if (specifier.isTypeOnly) { + if (isTypeOnly && specifier.isTypeOnly) { return grammarErrorOnFirstToken( specifier, specifier.kind === SyntaxKind.ImportSpecifier ? Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } + const exported = specifier.propertyName || specifier.name; + if (isExportLocal && exported.kind === SyntaxKind.StringLiteral) { + return grammarErrorOnNode(exported, Diagnostics.String_literal_module_export_names_must_be_followed_by_a_from_clause); + } + + if (checkString) { + if (specifier.name.kind === SyntaxKind.StringLiteral && !isIdentifierText(specifier.name.text, languageVersion)) { + return grammarErrorOnNode(specifier.name, Diagnostics.String_literal_module_export_names_are_not_allowed_when_the_module_option_is_set_to_es2020_or_lower); + } + if (specifier.propertyName?.kind === SyntaxKind.StringLiteral && !isIdentifierText(specifier.propertyName.text, languageVersion)) { + return grammarErrorOnNode(specifier.propertyName, Diagnostics.String_literal_module_export_names_are_not_allowed_when_the_module_option_is_set_to_es2020_or_lower); + } + } }); } @@ -48986,7 +49040,7 @@ function isDeclarationNameOrImportPropertyName(name: Node): boolean { switch (name.parent.kind) { case SyntaxKind.ImportSpecifier: case SyntaxKind.ExportSpecifier: - return isIdentifier(name); + return isModuleExportName(name); default: return isDeclarationName(name); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 65ccc4cb18fdc..be9b967e92810 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1601,6 +1601,10 @@ "category": "Error", "code": 1490 }, + "String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower.": { + "category": "Error", + "code": 1491 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", @@ -1659,6 +1663,10 @@ "category": "Message", "code": 2212 }, + "String literal module export names must be followed by a 'from' clause.": { + "category": "Error", + "code": 2213 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 638ff154747fa..dfa1e16505bb1 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -175,6 +175,7 @@ import { isHoistedFunction, isHoistedVariableStatement, isIdentifier, + isIdentifierText, isImportDeclaration, isImportEqualsDeclaration, isImportKeyword, @@ -313,6 +314,7 @@ import { ModuleBlock, ModuleBody, ModuleDeclaration, + ModuleExportName, ModuleKind, ModuleName, ModuleReference, @@ -983,6 +985,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode get createLogicalNot() { return getPrefixUnaryCreateFunction(SyntaxKind.ExclamationToken); }, get createPostfixIncrement() { return getPostfixUnaryCreateFunction(SyntaxKind.PlusPlusToken); }, get createPostfixDecrement() { return getPostfixUnaryCreateFunction(SyntaxKind.MinusMinusToken); }, + createModuleExportName, // Compound nodes createImmediatelyInvokedFunctionExpression, @@ -4713,7 +4716,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 |= @@ -4724,7 +4727,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; @@ -4747,7 +4750,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; @@ -4760,7 +4763,15 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier) { + function createModuleExportName(name: string, languageVersion: ScriptTarget): ModuleExportName; + function createModuleExportName(name: string | undefined, languageVersion: ScriptTarget): ModuleExportName | undefined; + function createModuleExportName(name: string | undefined, languageVersion: ScriptTarget): ModuleExportName | undefined { + if (name === undefined) return undefined; + return isIdentifierText(name, languageVersion) ? createIdentifier(name) : createStringLiteral(name); + } + + // @api + function updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: Identifier) { return node.isTypeOnly !== isTypeOnly || node.propertyName !== propertyName || node.name !== name @@ -4868,11 +4879,11 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // @api - function createExportSpecifier(isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier) { + function createExportSpecifier(isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: ModuleExportName) { const node = createBaseNode(SyntaxKind.ExportSpecifier); node.isTypeOnly = isTypeOnly; - node.propertyName = asName(propertyName); - node.name = asName(name); + node.propertyName = propertyName; + node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); @@ -4883,7 +4894,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 ffc8c4a44839d..f8d000f32a8e1 100644 --- a/src/compiler/factory/nodeTests.ts +++ b/src/compiler/factory/nodeTests.ts @@ -143,6 +143,7 @@ import { MissingDeclaration, ModuleBlock, ModuleDeclaration, + ModuleExportName, NamedExports, NamedImports, NamedTupleMember, @@ -321,6 +322,10 @@ export function isPrivateIdentifier(node: Node): node is PrivateIdentifier { return node.kind === SyntaxKind.PrivateIdentifier; } +export function isModuleExportName(node: Node): node is ModuleExportName { + return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral; +} + // Reserved Words /** @internal */ diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 2e2721eadcaaf..7cc936efde63c 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -792,7 +792,9 @@ export function getOrCreateExternalHelpersModuleNameIfNeeded(factory: NodeFactor } /** - * Get the name of that target module from an import or export declaration + * Get the name of that target module from an import or export declaration. + * + * This is only used in AMD and SystemJS emit. * * @internal */ @@ -800,7 +802,9 @@ export function getLocalNameForExternalImport(factory: NodeFactory, node: Import const namespaceDeclaration = getNamespaceDeclarationNode(node); if (namespaceDeclaration && !isDefaultImport(node) && !isExportNamespaceAsDefaultDeclaration(node)) { const name = namespaceDeclaration.name; - return isGeneratedIdentifier(name) ? name : factory.createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, name) || idText(name)); + if (isGeneratedIdentifier(name)) return name; + if (name.kind === SyntaxKind.StringLiteral) return factory.getGeneratedNameForNode(name); + return factory.createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, name) || idText(name)); } if (node.kind === SyntaxKind.ImportDeclaration && node.importClause) { return factory.getGeneratedNameForNode(node); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index eb2da7e8fc344..068a90601fcd2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -120,7 +120,6 @@ import { ImportClause, ImportDeclaration, ImportEqualsDeclaration, - ImportOrExportSpecifier, ImportSpecifier, ImportTypeAssertionContainer, ImportTypeNode, @@ -253,6 +252,7 @@ import { modifiersToFlags, ModuleBlock, ModuleDeclaration, + ModuleExportName, ModuleKind, Mutable, NamedExportBindings, @@ -2874,7 +2874,7 @@ namespace Parser { if (token() === SyntaxKind.FromKeyword && lookAhead(nextTokenIsStringLiteral)) { return false; } - return tokenIsIdentifierOrKeyword(token()); + return token() === SyntaxKind.StringLiteral || tokenIsIdentifierOrKeyword(token()); case ParsingContext.JsxAttributes: return tokenIsIdentifierOrKeyword(token()) || token() === SyntaxKind.OpenBraceToken; case ParsingContext.JsxChildren: @@ -8357,22 +8357,26 @@ namespace Parser { return parseImportOrExportSpecifier(SyntaxKind.ImportSpecifier) as ImportSpecifier; } - function parseImportOrExportSpecifier(kind: SyntaxKind): ImportOrExportSpecifier { + function parseImportOrExportSpecifier(kind: SyntaxKind) { const pos = getNodePos(); + // ModuleExportName: + // Identifier + // StringLiteral // 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 mustParseAsKeyword = false; + 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: // @@ -8380,6 +8384,7 @@ namespace Parser { // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as + // export { type as as "s" } from "mod";- isTypeOnly: true, name: "s", propertyName: as if (token() === SyntaxKind.AsKeyword) { // { type as ...? } const firstAs = parseIdentifierName(); @@ -8388,9 +8393,10 @@ namespace Parser { const secondAs = parseIdentifierName(); if (tokenIsIdentifierOrKeyword(token())) { // { type as as something } + // { type as as "something" } (only in exports) isTypeOnly = true; propertyName = firstAs; - name = parseNameWithKeywordCheck(); + name = parseModuleExportNameOnlyForExports(); canParseAsKeyword = false; } else { @@ -8404,7 +8410,7 @@ namespace Parser { // { type as something } propertyName = name; canParseAsKeyword = false; - name = parseNameWithKeywordCheck(); + name = parseModuleExportNameOnlyForExports(); } else { // { type as } @@ -8412,23 +8418,35 @@ namespace Parser { name = firstAs; } } + // export { type "x" } + // import { type "x" as ... } + else if (token() === SyntaxKind.StringLiteral) { + isTypeOnly = true; + if (kind === SyntaxKind.ImportSpecifier) mustParseAsKeyword = true; + name = parseModuleExportName(parseNameWithKeywordCheck); + } else if (tokenIsIdentifierOrKeyword(token())) { // { type something ...? } isTypeOnly = true; name = parseNameWithKeywordCheck(); } } + // import { "x" as ... } + else if (kind === SyntaxKind.ImportSpecifier && name.kind === SyntaxKind.StringLiteral) { + mustParseAsKeyword = true; + } - if (canParseAsKeyword && token() === SyntaxKind.AsKeyword) { + if (mustParseAsKeyword || (canParseAsKeyword && token() === SyntaxKind.AsKeyword)) { propertyName = name; parseExpected(SyntaxKind.AsKeyword); - name = parseNameWithKeywordCheck(); + name = parseModuleExportNameOnlyForExports(); } if (kind === SyntaxKind.ImportSpecifier && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected); } + if (kind === SyntaxKind.ImportSpecifier) Debug.assert(name.kind === SyntaxKind.Identifier); 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); @@ -8438,10 +8456,22 @@ namespace Parser { checkIdentifierEnd = scanner.getTokenEnd(); return parseIdentifierName(); } + function parseModuleExportNameOnlyForExports() { + if (kind === SyntaxKind.ImportSpecifier) return parseNameWithKeywordCheck(); + return parseModuleExportName(parseNameWithKeywordCheck); + } + function parseModuleExportName(parser: () => Identifier): ModuleExportName { + if (token() === SyntaxKind.StringLiteral) return parseStringLiteral(); + return parser(); + } + function parseStringLiteral(): StringLiteral { + // TODO: the spec requires it pass IsStringWellFormedUnicode + return parseLiteralLikeNode(SyntaxKind.StringLiteral) as StringLiteral; + } } function parseNamespaceExport(pos: number): NamespaceExport { - return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos); + return finishNode(factory.createNamespaceExport(token() === SyntaxKind.StringLiteral ? parseLiteralLikeNode(SyntaxKind.StringLiteral) as StringLiteral : parseIdentifierName()), pos); } function parseExportDeclaration(pos: number, hasJSDoc: boolean, modifiers: NodeArray | undefined): ExportDeclaration { diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 4be05fd79eb06..d0e9ef4c90b62 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -59,6 +59,7 @@ import { getDirectoryPath, getEffectiveBaseTypeNode, getEffectiveModifierFlags, + getEmitScriptTarget, getExternalModuleImportEqualsDeclarationExpression, getExternalModuleNameFromDeclaration, getFirstConstructorWithBody, @@ -1520,7 +1521,7 @@ export function transformDeclarations(context: TransformationContext) { /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports(map(exportMappings, ([gen, exp]) => { - return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); + return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, factory.createModuleExportName(exp, getEmitScriptTarget(context.getCompilerOptions()))); })) )); } diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts index 879544063f9f0..01991d0f69aac 100644 --- a/src/compiler/transformers/module/esnextAnd2015.ts +++ b/src/compiler/transformers/module/esnextAnd2015.ts @@ -10,6 +10,7 @@ import { EmitHint, ExportAssignment, ExportDeclaration, + ExportSpecifier, Expression, GeneratedIdentifierFlags, getEmitFlags, @@ -22,17 +23,21 @@ import { idText, ImportDeclaration, ImportEqualsDeclaration, + ImportSpecifier, insertStatementsAfterCustomPrologue, isExportNamespaceAsDefaultDeclaration, isExternalModule, isExternalModuleImportEqualsDeclaration, isExternalModuleIndicator, isIdentifier, + isIdentifierText, isNamespaceExport, isSourceFile, isStatement, ModifierFlags, + ModuleExportName, ModuleKind, + NamedImports, Node, NodeFlags, ScriptTarget, @@ -119,6 +124,8 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S function visitor(node: Node): VisitResult { switch (node.kind) { + case SyntaxKind.ImportDeclaration: + return visitImportDeclaration(node as ImportDeclaration); case SyntaxKind.ImportEqualsDeclaration: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` @@ -185,6 +192,73 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S return factory.createCallExpression(factory.cloneNode(name), /*typeArguments*/ undefined, args); } + /** + * Visits an ImportDeclaration node. + * + * @param node The node to visit. + */ + function visitImportDeclaration(node: ImportDeclaration): VisitResult { + if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.ES2020) return node; + if (node.importClause?.namedBindings?.kind !== SyntaxKind.NamedImports) return node; + + const clause = node.importClause; + const substitutions: ImportSpecifier[] = []; + let needUpdate = false; + const bindings = clause.namedBindings as NamedImports; + const nextImports: ImportSpecifier[] = []; + for (const element of bindings.elements) { + if (element.propertyName?.kind === SyntaxKind.StringLiteral) { + const id = tryConvertModuleExportNameToIdentifier(element.propertyName); + if (id) { + needUpdate = true; + nextImports.push(factory.updateImportSpecifier(element, element.isTypeOnly, id, element.name)); + } + else { + substitutions.push(element); + } + } + else nextImports.push(element); + } + if (!needUpdate && !substitutions.length) return node; + node = factory.updateImportDeclaration( + node, + node.modifiers, + factory.updateImportClause(clause, clause.isTypeOnly, clause.name, factory.updateNamedImports(bindings, nextImports)), + node.moduleSpecifier, + node.assertClause + ); + if (!substitutions.length) return node; + const nsImportName = factory.getGeneratedNameForNode(node); + for (const element of substitutions) { + // TODO: this does not support ESM live binding. Not worth to introduce so much node substitute code for this? + context.addInitializationStatement( + factory.createVariableStatement( + /*modifiers*/ undefined, + factory.createVariableDeclarationList( + [factory.createVariableDeclaration( + element.name, + /*exclamationToken*/ undefined, + /*type*/ undefined, + factory.createElementAccessExpression( + nsImportName, + element.propertyName! + ) + )], + NodeFlags.Const + ) + ) + ); + } + const nsImport = factory.createImportDeclaration( + node.modifiers, + factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, factory.createNamespaceImport(nsImportName)), + node.moduleSpecifier, + node.assertClause + ); + if (!clause.name && nextImports.length === 0) return nsImport; + return [node, nsImport]; + } + /** * Visits an ImportEqualsDeclaration node. * @@ -226,7 +300,7 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S statements = append(statements, factory.createExportDeclaration( /*modifiers*/ undefined, node.isTypeOnly, - factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, idText(node.name))]) + factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, node.name)]) )); } return statements; @@ -237,7 +311,61 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S return node.isExportEquals ? undefined : node; } + function tryConvertModuleExportNameToIdentifier(node: ModuleExportName): Identifier | undefined { + if (node.kind === SyntaxKind.Identifier) return node; + if (!isIdentifierText(node.text, languageVersion)) return undefined; + const id = factory.createIdentifier(node.text); + setOriginalNode(id, node); + return id; + } + function visitExportDeclaration(node: ExportDeclaration) { + // transform StringLiteral to Identifier when it's possible. + if (compilerOptions.module === ModuleKind.ES2015 || compilerOptions.module === ModuleKind.ES2020) { + const clause = node.exportClause; + if (clause?.kind === SyntaxKind.NamespaceExport && clause.name.kind === SyntaxKind.StringLiteral) { + const id = tryConvertModuleExportNameToIdentifier(clause.name); + if (id) { + node = factory.updateExportDeclaration( + node, + node.modifiers, + node.isTypeOnly, + factory.updateNamespaceExport(clause, id), + node.moduleSpecifier, + node.assertClause + ); + } + else return undefined; + } + if (clause?.kind === SyntaxKind.NamedExports) { + const nextExports: ExportSpecifier[] = []; + let needUpdate = false; + for (const element of clause.elements) { + const exported = element.propertyName || element.name; + // ill-formed + if (exported.kind === SyntaxKind.StringLiteral && !node.moduleSpecifier) return node; + const prop = element.propertyName && tryConvertModuleExportNameToIdentifier(element.propertyName); + const name = tryConvertModuleExportNameToIdentifier(element.name); + if (element.name !== name || prop !== element.propertyName) { + needUpdate = true; + if ((element.propertyName && !prop) || !name) continue; + nextExports.push(factory.updateExportSpecifier(element, element.isTypeOnly, prop, name || element.name)); + } + else nextExports.push(element); + } + if (needUpdate) { + node = factory.updateExportDeclaration( + node, + node.modifiers, + node.isTypeOnly, + factory.updateNamedExports(clause, nextExports), + node.moduleSpecifier, + node.assertClause + ); + } + } + } + // `export * as ns` only needs to be transformed in ES2015 if (compilerOptions.module !== undefined && compilerOptions.module > ModuleKind.ES2015) { return node; diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index fc95446ce54c2..88523690a933f 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -17,6 +17,7 @@ import { chainBundle, ClassDeclaration, collectExternalModuleInfo, + createElementAccessOrPropertyAccessExpression, Debug, Declaration, DefaultClause, @@ -118,6 +119,8 @@ import { mapDefined, Modifier, ModifierFlags, + ModuleExportName, + moduleExportNameText, ModuleKind, Node, NodeArray, @@ -267,7 +270,7 @@ 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) => factory.createAssignment(createElementAccessOrPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(nextId)), prev), factory.createVoidZero() as Expression ) ) @@ -594,7 +597,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile append(statements, createUnderscoreUnderscoreESModule()); } if (length(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) => factory.createAssignment(createElementAccessOrPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(nextId)), prev), factory.createVoidZero() as Expression))); } // Visit each statement of the module body. @@ -1587,8 +1590,8 @@ export function transformModule(context: TransformationContext): (x: SourceFile const exportNeedsImportDefault = !!getESModuleInterop(compilerOptions) && !(getInternalEmitFlags(node) & InternalEmitFlags.NeverApplyImportHelper) && - idText(specifier.propertyName || specifier.name) === "default"; - const exportedValue = factory.createPropertyAccessExpression( + moduleExportNameText(specifier.propertyName || specifier.name) === "default"; + const exportedValue = createElementAccessOrPropertyAccessExpression( exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push( @@ -1619,7 +1622,10 @@ export function transformModule(context: TransformationContext): (x: SourceFile getHelperExpressionForExport(node, moduleKind !== ModuleKind.AMD ? createRequireCall(node) : isExportNamespaceAsDefaultDeclaration(node) ? generatedName : - factory.createIdentifier(idText(node.exportClause.name))) + node.exportClause.name.kind === SyntaxKind.Identifier ? + factory.createIdentifier(idText(node.exportClause.name)) : + factory.getGeneratedNameForNode(node.exportClause.name) + ) ) ), node @@ -2037,7 +2043,7 @@ 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, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean): Statement[] | undefined { + function appendExportStatement(statements: Statement[] | undefined, exportName: ModuleExportName, expression: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean): Statement[] | undefined { statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding)); return statements; } @@ -2079,7 +2085,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) { @@ -2096,7 +2102,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 && languageVersion !== ScriptTarget.ES3 ? factory.createCallExpression( factory.createPropertyAccessExpression( @@ -2121,7 +2127,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile ]) ] ) : factory.createAssignment( - factory.createPropertyAccessExpression( + createElementAccessOrPropertyAccessExpression( factory.createIdentifier("exports"), factory.cloneNode(name) ), @@ -2320,7 +2326,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile else if (isImportSpecifier(importDeclaration)) { const name = importDeclaration.propertyName || importDeclaration.name; return setTextRange( - factory.createPropertyAccessExpression( + createElementAccessOrPropertyAccessExpression( factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), factory.cloneNode(name) ), diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 4e2d9b954e626..ffd0cc2cdd512 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -12,6 +12,7 @@ import { chainBundle, ClassDeclaration, collectExternalModuleInfo, + createElementAccessOrPropertyAccessExpression, Debug, Declaration, DefaultClause, @@ -89,6 +90,8 @@ import { map, MetaProperty, ModifierFlags, + moduleExportNameText, + moduleExportNameTextEscaped, moveEmitHelpers, Node, NodeFlags, @@ -452,7 +455,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 (moduleExportNameTextEscaped(exportedLocalName) === "default") { continue; } @@ -626,10 +629,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(moduleExportNameText(e.name)), factory.createElementAccessExpression( parameterName, - factory.createStringLiteral(idText(e.propertyName || e.name)) + factory.createStringLiteral(moduleExportNameText(e.propertyName || e.name)) ) ) ); @@ -652,7 +655,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc exportFunction, /*typeArguments*/ undefined, [ - factory.createStringLiteral(idText(entry.exportClause.name)), + factory.createStringLiteral(moduleExportNameText(entry.exportClause.name)), parameterName ] ) @@ -1117,7 +1120,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc const exportSpecifiers = moduleInfo.exportSpecifiers.get(idText(name)); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { - if (exportSpecifier.name.escapedText !== excludeName) { + if (moduleExportNameTextEscaped(exportSpecifier.name) !== excludeName) { statements = appendExportStatement(statements, exportSpecifier.name, name); } } @@ -1806,7 +1809,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc return setTextRange( factory.createPropertyAssignment( factory.cloneNode(name), - factory.createPropertyAccessExpression( + createElementAccessOrPropertyAccessExpression( factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), factory.cloneNode(importDeclaration.propertyName || importDeclaration.name) ), @@ -1872,7 +1875,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc } else if (isImportSpecifier(importDeclaration)) { return setTextRange( - factory.createPropertyAccessExpression( + createElementAccessOrPropertyAccessExpression( factory.getGeneratedNameForNode(importDeclaration.parent?.parent?.parent || importDeclaration), factory.cloneNode(importDeclaration.propertyName || importDeclaration.name) ), diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index c094a8dc0e76c..af2e1bf4bb1a9 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -66,6 +66,9 @@ import { map, MethodDeclaration, ModifierFlags, + ModuleExportName, + moduleExportNameText, + moduleExportNameTextEscaped, NamedImportBindings, NamespaceExport, Node, @@ -99,7 +102,7 @@ export interface ExternalModuleInfo { externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers exportSpecifiers: Map; // 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 + exportedNames: ModuleExportName[] | undefined; // all exported names in the module, both local and reexported exportEquals: ExportAssignment | undefined; // an export= declaration if one was present hasExportStarsToExportValues: boolean; // whether this module contains export* } @@ -111,7 +114,7 @@ function containsDefaultReference(node: NamedImportBindings | undefined) { } function isNamedDefaultReference(e: ImportSpecifier): boolean { - return e.propertyName !== undefined && e.propertyName.escapedText === InternalSymbolName.Default; + return e.propertyName !== undefined && moduleExportNameTextEscaped(e.propertyName) === InternalSymbolName.Default; } /** @internal */ @@ -164,7 +167,7 @@ export function collectExternalModuleInfo(context: TransformationContext, source const exportSpecifiers = createMultiMap(); const exportedBindings: Identifier[][] = []; const uniqueExports = new Map(); - let exportedNames: Identifier[] | undefined; + let exportedNames: ModuleExportName[] | undefined; let hasExportDefault = false; let exportEquals: ExportAssignment | undefined; let hasExportStarsToExportValues = false; @@ -211,9 +214,10 @@ export function collectExternalModuleInfo(context: TransformationContext, source } else { const name = ((node as ExportDeclaration).exportClause as NamespaceExport).name; - if (!uniqueExports.get(idText(name))) { + const nameText = moduleExportNameText(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` @@ -295,27 +299,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))) { + if (!uniqueExports.get(moduleExportNameText(specifier.name))) { const name = specifier.propertyName || specifier.name; - if (!node.moduleSpecifier) { + if (!node.moduleSpecifier && name.kind === SyntaxKind.Identifier) { exportSpecifiers.add(idText(name), specifier); } - const decl = resolver.getReferencedImportDeclaration(name) - || resolver.getReferencedValueDeclaration(name); + // export { "x" as ... } cannot be resolved locally. + if (name.kind === SyntaxKind.Identifier) { + 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(moduleExportNameText(specifier.name), 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 d5c402ea30784..7fa3678454acd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3733,7 +3733,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 { @@ -3773,7 +3773,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; } @@ -3782,10 +3782,11 @@ 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 @@ -5681,7 +5682,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; isRequiredInitializedParameter(node: ParameterDeclaration): boolean; isOptionalUninitializedParameterProperty(node: ParameterDeclaration): boolean; @@ -5949,6 +5950,8 @@ export interface ReverseMappedSymbol extends TransientSymbol { links: ReverseMappedSymbolLinks; } +// All names should starts with __, since it's possible to declare an arbitrary symbol name with +// export { ident as "this" } export const enum InternalSymbolName { Call = "__call", // Call signatures Constructor = "__constructor", // Constructor implementations @@ -8625,20 +8628,20 @@ export interface NodeFactory { updateImportTypeAssertionContainer(node: ImportTypeAssertionContainer, clause: AssertClause, multiLine?: boolean): ImportTypeAssertionContainer; 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, assertClause?: AssertClause): ExportDeclaration; updateExportDeclaration(node: ExportDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | 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: ModuleExportName | undefined, name: ModuleExportName): ExportSpecifier; + updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: ModuleExportName | undefined, name: ModuleExportName): ExportSpecifier; /** @internal */ createMissingDeclaration(): MissingDeclaration; // @@ -8870,6 +8873,8 @@ export interface NodeFactory { createLogicalNot(operand: Expression): PrefixUnaryExpression; createPostfixIncrement(operand: Expression): PostfixUnaryExpression; createPostfixDecrement(operand: Expression): PostfixUnaryExpression; + createModuleExportName(name: string, languageVersion: ScriptTarget): ModuleExportName; + createModuleExportName(name: string | undefined, languageVersion: ScriptTarget): ModuleExportName | undefined; // // Compound Nodes diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 54b8f92786698..c462b2c4bd1ca 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -392,6 +392,7 @@ import { ModuleBlock, ModuleDeclaration, ModuleDetectionKind, + ModuleExportName, ModuleKind, ModuleResolutionKind, moduleResolutionOptionDeclarations, @@ -1206,7 +1207,7 @@ 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) && moduleExportNameTextEscaped(node.exportClause.name) === "default"); } /** @internal */ @@ -2042,7 +2043,7 @@ export function forEachEnclosingBlockScopeContainer(node: Node, cb: (container: // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. /** @internal */ -export function declarationNameToString(name: DeclarationName | QualifiedName | undefined) { +export function declarationNameToString(name: DeclarationName | QualifiedName | ModuleExportName | undefined) { return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } @@ -3872,6 +3873,12 @@ export function getElementOrPropertyAccessName(node: AccessExpression): __String return undefined; } +/** @internal */ +export function createElementAccessOrPropertyAccessExpression(lhs: Expression, rhs: Expression) { + if (isMemberName(rhs)) return factory.createPropertyAccessExpression(lhs, rhs); + return factory.createElementAccessExpression(lhs, rhs); +} + /** @internal */ export function getAssignmentDeclarationPropertyAccessKind(lhs: AccessExpression): AssignmentDeclarationKind { if (lhs.expression.kind === SyntaxKind.ThisKeyword) { @@ -4022,6 +4029,10 @@ export function getExternalModuleName(node: AnyImportOrReExport | ImportTypeNode } /** @internal */ +export function getNamespaceDeclarationNode(node: ImportDeclaration): NamespaceImport | undefined; +export function getNamespaceDeclarationNode(node: ImportEqualsDeclaration): ImportEqualsDeclaration; +export function getNamespaceDeclarationNode(node: ExportDeclaration): NamespaceExport | undefined; +export function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport | NamespaceExport | undefined; export function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport | NamespaceExport | undefined { switch (node.kind) { case SyntaxKind.ImportDeclaration: @@ -10270,3 +10281,18 @@ export function getTextOfJsxNamespacedName(node: JsxNamespacedName) { export function intrinsicTagNameToString(node: Identifier | JsxNamespacedName) { return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node); } + +/** @internal */ +export function moduleExportNameText(node: ModuleExportName): string { + if (node.kind === SyntaxKind.StringLiteral) return node.text; + return idText(node); +} +/** @internal */ +export function moduleExportNameTextEscaped(node: ModuleExportName): __String { + if (node.kind === SyntaxKind.StringLiteral) return escapeLeadingUnderscores(node.text); + return node.escapedText; +} +export function isModuleExportNameStringLiteral(node: __String | ModuleExportName | undefined): node is StringLiteral { + if (!node) return false; + return typeof node !== "string" && node.kind === SyntaxKind.StringLiteral; +} diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 4d0220bdf4308..2ef6d93ab5c4a 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -851,8 +851,8 @@ function getDeclarationIdentifier(node: Declaration | Expression): Identifier | } /** @internal */ -export function nodeHasName(statement: Node, name: Identifier) { - if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name as Identifier) === idText(name)) { +export function nodeHasName(statement: Node, name: Identifier | string) { + if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name) === (typeof name === "string" ? name : idText(name))) { return true; } if (isVariableStatement(statement) && some(statement.declarationList.declarations, d => nodeHasName(d, name))) { diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 08475d5c0ae7a..c114b169cebb0 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -59,6 +59,7 @@ import { isModifier, isModifierLike, isModuleBody, + isModuleExportName, isModuleName, isModuleReference, isNamedExportBindings, @@ -1355,7 +1356,7 @@ const visitEachChildTable: VisitEachChildTable = { [SyntaxKind.NamespaceExport]: function visitEachChildOfNamespaceExport(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { return context.factory.updateNamespaceExport(node, - Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))); + Debug.checkDefined(nodeVisitor(node.name, visitor, isModuleExportName))); }, [SyntaxKind.NamedImports]: function visitEachChildOfNamedImports(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { @@ -1366,7 +1367,7 @@ const visitEachChildTable: VisitEachChildTable = { [SyntaxKind.ImportSpecifier]: function visitEachChildOfImportSpecifier(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { return context.factory.updateImportSpecifier(node, node.isTypeOnly, - nodeVisitor(node.propertyName, visitor, isIdentifier), + nodeVisitor(node.propertyName, visitor, isModuleExportName), Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier))); }, @@ -1393,8 +1394,8 @@ const visitEachChildTable: VisitEachChildTable = { [SyntaxKind.ExportSpecifier]: function visitEachChildOfExportSpecifier(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { 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))); }, // Module references diff --git a/src/services/codefixes/convertToEsModule.ts b/src/services/codefixes/convertToEsModule.ts index b15a0521c1cb1..356876dbefb7b 100644 --- a/src/services/codefixes/convertToEsModule.ts +++ b/src/services/codefixes/convertToEsModule.ts @@ -376,7 +376,7 @@ function convertNamedExport( */ const newNodes = [ makeConst(/*modifiers*/ undefined, rename, assignment.right), - makeExportDeclaration([factory.createExportSpecifier(/*isTypeOnly*/ false, rename, text)]), + makeExportDeclaration([factory.createExportSpecifier(/*isTypeOnly*/ false, factory.createModuleExportName(rename, ScriptTarget.ESNext), factory.createModuleExportName(text, ScriptTarget.ESNext))]), ]; changes.replaceNodeWithNodes(sourceFile, assignment.parent, newNodes); } @@ -399,7 +399,7 @@ function reExportStar(moduleSpecifier: string): ExportDeclaration { return makeExportDeclaration(/*exportSpecifiers*/ undefined, moduleSpecifier); } function reExportDefault(moduleSpecifier: string): ExportDeclaration { - return makeExportDeclaration([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, "default")], moduleSpecifier); + return makeExportDeclaration([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, factory.createIdentifier("default"))], moduleSpecifier); } function convertExportsPropertyAssignment({ left, right, parent }: BinaryExpression & { left: PropertyAccessExpression }, sourceFile: SourceFile, changes: textChanges.ChangeTracker): void { diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts index bae3f2d2c0f16..1124d10a305a0 100644 --- a/src/services/codefixes/fixInvalidImportSyntax.ts +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -18,7 +18,6 @@ import { isTransientSymbol, makeImport, ModuleKind, - NamespaceImport, NewExpression, Node, SourceFile, @@ -34,7 +33,7 @@ const fixName = "invalidImportSyntax"; function getCodeFixesForImportDeclaration(context: CodeFixContext, node: ImportDeclaration): CodeFixAction[] { const sourceFile = getSourceFileOfNode(node); - const namespace = getNamespaceDeclarationNode(node) as NamespaceImport; + const namespace = getNamespaceDeclarationNode(node)!; const opts = context.program.getCompilerOptions(); const variations: CodeFixAction[] = []; diff --git a/src/services/completions.ts b/src/services/completions.ts index 0becb60309ed2..525e89a8cd21a 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -285,6 +285,7 @@ import { ModifierSyntaxKind, modifierToFlag, ModuleDeclaration, + moduleExportNameTextEscaped, ModuleReference, moduleResolutionSupportsPackageJsonExportsAndImports, NamedImportBindings, @@ -1747,6 +1748,16 @@ function createCompletionEntry( data = originToCompletionEntryData(origin); hasAction = !importStatementCompletion; } + const parentNamedImportOrExport = findAncestor(location, isNamedImportsOrExports); + if (parentNamedImportOrExport && !isIdentifierText(name, ScriptTarget.Latest)) { + if (parentNamedImportOrExport.kind === SyntaxKind.NamedImports) { + insertText = `${quotePropertyName(sourceFile, preferences, name)} as $\{1:item}`; + isSnippet = true; + } + else { + insertText = quotePropertyName(sourceFile, preferences, name); + } + } // TODO(drosen): Right now we just permit *all* semantic meanings when calling // 'getSymbolKind' which is permissible given that it is backwards compatible; but @@ -2450,7 +2461,7 @@ export function getCompletionEntriesFromSymbols( for (let i = 0; i < symbols.length; i++) { const symbol = symbols[i]; const origin = symbolToOriginInfoMap?.[i]; - const info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); + const info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected, !!findAncestor(location, isNamedImportsOrExports)); if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === CompletionKind.Global && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } @@ -2660,7 +2671,7 @@ function getSymbolCompletionFromEntryId( // completion entry. return firstDefined(symbols, (symbol, index): SymbolCompletion | undefined => { const origin = symbolToOriginInfoMap[index]; - const info = getCompletionEntryDisplayNameForSymbol(symbol, getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); + const info = getCompletionEntryDisplayNameForSymbol(symbol, getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected, !!completionData.importStatementCompletion); return info && info.name === entryId.name && ( entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & SymbolFlags.ClassMember || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (SymbolFlags.Property | SymbolFlags.Method) @@ -3954,7 +3965,9 @@ function getCompletionData( getEmitScriptTarget(compilerOptions), /*origin*/ undefined, CompletionKind.ObjectPropertyDeclaration, - /*jsxIdentifierExpected*/ false); + /*jsxIdentifierExpected*/ false, + /*moduleExportNameExpected*/ false, + ); if (!displayName) { return; } @@ -4282,7 +4295,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) { @@ -4793,7 +4806,9 @@ function getCompletionData( target, origin, CompletionKind.ObjectPropertyDeclaration, - /*jsxIdentifierExpected*/ false); + /*jsxIdentifierExpected*/ false, + /*moduleExportNameExpected*/ false + ); if (displayName) { const originalSortText = symbolToSortTextMap[symbolId] ?? SortText.LocationPriority; const { name } = displayName; @@ -4944,6 +4959,7 @@ function getCompletionEntryDisplayNameForSymbol( origin: SymbolOriginInfo | undefined, kind: CompletionKind, jsxIdentifierExpected: boolean, + moduleExportNameExpected: boolean ): CompletionEntryDisplayNameForSymbol | undefined { if (originIsIgnore(origin)) { return undefined; @@ -4959,6 +4975,9 @@ function getCompletionEntryDisplayNameForSymbol( } const validNameResult: CompletionEntryDisplayNameForSymbol = { name, needsConvertPropertyAccess: false }; + if (moduleExportNameExpected) { + return validNameResult; + } if (isIdentifierText(name, target, jsxIdentifierExpected ? LanguageVariant.JSX : LanguageVariant.Standard) || symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 1aa55a6cbc2cf..268287766f7a2 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -191,6 +191,8 @@ import { MethodDeclaration, ModifierFlags, ModuleDeclaration, + ModuleExportName, + moduleExportNameTextEscaped, MultiMap, NamedDeclaration, Node, @@ -1519,7 +1521,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); @@ -1927,7 +1929,7 @@ export namespace Core { } function getReferencesAtExportSpecifier( - referenceLocation: Identifier, + referenceLocation: ModuleExportName, referenceSymbol: Symbol, exportSpecifier: ExportSpecifier, search: Search, @@ -1946,7 +1948,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 && (moduleExportNameTextEscaped(name) === InternalSymbolName.Default))) { addRef(); } } @@ -1969,8 +1971,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 = moduleExportNameTextEscaped(referenceLocation) === "default" + || moduleExportNameTextEscaped(exportSpecifier.name) === "default"; const exportKind = isDefaultExport ? ExportKind.Default : ExportKind.Named; const exportSymbol = Debug.checkDefined(exportSpecifier.symbol); const exportInfo = getExportInfo(exportSymbol, exportKind, state.checker); @@ -1990,11 +1992,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 3688a688c53d8..86ae653132d60 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -58,9 +58,11 @@ import { isFunctionTypeNode, isIdentifier, isImportMeta, + isImportOrExportSpecifier, isJSDocOverrideTag, isJsxOpeningLikeElement, isJumpStatementTarget, + isModuleExportName, isModuleSpecifierLike, isNameOfFunctionDeclaration, isNewExpressionTarget, @@ -516,6 +518,9 @@ 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 (isModuleExportName(node) && isImportOrExportSpecifier(declaration)) { + return true; + } if (node.kind !== SyntaxKind.Identifier) { return false; } diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index f79eb63627f3c..78177d6a7fa0b 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -60,6 +60,8 @@ import { ModifierFlags, ModuleBlock, ModuleDeclaration, + ModuleExportName, + moduleExportNameTextEscaped, NamedImportsOrExports, NamespaceImport, Node, @@ -88,9 +90,9 @@ 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)[]; + singleReferences: readonly ModuleExportName[]; /** List of source files that may (or may not) use the symbol via a namespace. (For UMD modules this is every file.) */ indirectUsers: readonly SourceFile[]; } @@ -307,9 +309,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 singleReferences: (Identifier | StringLiteral)[] = []; - function addSearch(location: Identifier, symbol: Symbol): void { + const importSearches: [ModuleExportName, Symbol][] = []; + const singleReferences: ModuleExportName[] = []; + function addSearch(location: ModuleExportName, symbol: Symbol): void { importSearches.push([location, symbol]); } @@ -405,7 +407,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; } @@ -414,7 +416,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 573f908abf974..522cc946e6bbd 100644 --- a/src/services/organizeImports.ts +++ b/src/services/organizeImports.ts @@ -48,6 +48,7 @@ import { map, MemoizeCache, memoizeCached, + moduleExportNameTextEscaped, NamedImportBindings, NamedImports, NamespaceImport, @@ -763,7 +764,7 @@ function getImportKindOrder(s1: AnyImportOrRequireStatement) { 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 && importSpecifier.name.escapedText === 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 0509e1e0c512b..891c7621e014a 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, @@ -232,7 +233,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: @@ -278,7 +279,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/testRunner/unittests/transform.ts b/src/testRunner/unittests/transform.ts index aa277bd21f536..9e9f001e3d0fd 100644 --- a/src/testRunner/unittests/transform.ts +++ b/src/testRunner/unittests/transform.ts @@ -282,7 +282,7 @@ describe("unittests:: TransformAPI", () => { if (node.kind === ts.SyntaxKind.ExportDeclaration) { const ed = node as ts.Node as ts.ExportDeclaration; const exports = [{ name: "x" }]; - const exportSpecifiers = exports.map(e => ts.factory.createExportSpecifier(/*isTypeOnly*/ false, e.name, e.name)); + const exportSpecifiers = exports.map(e => ts.factory.createExportSpecifier(/*isTypeOnly*/ false, ts.factory.createModuleExportName(e.name, ts.ScriptTarget.ESNext), ts.factory.createModuleExportName(e.name, ts.ScriptTarget.ESNext))); const exportClause = ts.factory.createNamedExports(exportSpecifiers); const newEd = ts.factory.updateExportDeclaration(ed, ed.modifiers, ed.isTypeOnly, exportClause, ed.moduleSpecifier, ed.assertClause); @@ -697,4 +697,3 @@ function test () { }).outputText; }); }); - diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 56c4b49ff6df2..dca8374261a2c 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -5752,7 +5752,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; @@ -5783,7 +5783,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; } @@ -5791,9 +5791,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 = ImportClause & { @@ -7875,20 +7876,20 @@ declare namespace ts { updateImportTypeAssertionContainer(node: ImportTypeAssertionContainer, clause: AssertClause, multiLine?: boolean): ImportTypeAssertionContainer; 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, assertClause?: AssertClause): ExportDeclaration; updateExportDeclaration(node: ExportDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | 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: ModuleExportName | undefined, name: 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; @@ -8057,6 +8058,8 @@ declare namespace ts { createLogicalNot(operand: Expression): PrefixUnaryExpression; createPostfixIncrement(operand: Expression): PostfixUnaryExpression; createPostfixDecrement(operand: Expression): PostfixUnaryExpression; + createModuleExportName(name: string, languageVersion: ScriptTarget): ModuleExportName; + createModuleExportName(name: string | undefined, languageVersion: ScriptTarget): ModuleExportName | undefined; createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; @@ -8824,6 +8827,9 @@ declare namespace ts { parent: ConstructorDeclaration; name: Identifier; }; + function getNamespaceDeclarationNode(node: ImportEqualsDeclaration): ImportEqualsDeclaration; + function getNamespaceDeclarationNode(node: ExportDeclaration): NamespaceExport | undefined; + function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport | NamespaceExport | undefined; /** * This function checks multiple locations for JSDoc comments that apply to a host node. * At each location, the whole comment may apply to the node, or only a specific tag in @@ -8844,6 +8850,7 @@ declare namespace ts { * ``` */ function getJSDocCommentsAndTags(hostNode: Node): readonly (JSDoc | JSDocTag)[]; + function isModuleExportNameStringLiteral(node: __String | ModuleExportName | undefined): node is StringLiteral; /** @deprecated */ function createUnparsedSourceFile(text: string): UnparsedSource; /** @deprecated */ @@ -8950,6 +8957,7 @@ declare namespace ts { function isEqualsGreaterThanToken(node: Node): node is EqualsGreaterThanToken; function isIdentifier(node: Node): node is Identifier; function isPrivateIdentifier(node: Node): node is PrivateIdentifier; + function isModuleExportName(node: Node): node is ModuleExportName; function isAssertsKeyword(node: Node): node is AssertsKeyword; function isAwaitKeyword(node: Node): node is AwaitKeyword; function isQualifiedName(node: Node): node is QualifiedName; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 2b642a091ce2e..2df4a05d6a781 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1699,7 +1699,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; @@ -1730,7 +1730,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; } @@ -1738,9 +1738,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 = ImportClause & { @@ -3822,20 +3823,20 @@ declare namespace ts { updateImportTypeAssertionContainer(node: ImportTypeAssertionContainer, clause: AssertClause, multiLine?: boolean): ImportTypeAssertionContainer; 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, assertClause?: AssertClause): ExportDeclaration; updateExportDeclaration(node: ExportDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | 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: ModuleExportName | undefined, name: 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; @@ -4004,6 +4005,8 @@ declare namespace ts { createLogicalNot(operand: Expression): PrefixUnaryExpression; createPostfixIncrement(operand: Expression): PostfixUnaryExpression; createPostfixDecrement(operand: Expression): PostfixUnaryExpression; + createModuleExportName(name: string, languageVersion: ScriptTarget): ModuleExportName; + createModuleExportName(name: string | undefined, languageVersion: ScriptTarget): ModuleExportName | undefined; createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; @@ -4771,6 +4774,9 @@ declare namespace ts { parent: ConstructorDeclaration; name: Identifier; }; + function getNamespaceDeclarationNode(node: ImportEqualsDeclaration): ImportEqualsDeclaration; + function getNamespaceDeclarationNode(node: ExportDeclaration): NamespaceExport | undefined; + function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport | NamespaceExport | undefined; /** * This function checks multiple locations for JSDoc comments that apply to a host node. * At each location, the whole comment may apply to the node, or only a specific tag in @@ -4791,6 +4797,7 @@ declare namespace ts { * ``` */ function getJSDocCommentsAndTags(hostNode: Node): readonly (JSDoc | JSDocTag)[]; + function isModuleExportNameStringLiteral(node: __String | ModuleExportName | undefined): node is StringLiteral; /** @deprecated */ function createUnparsedSourceFile(text: string): UnparsedSource; /** @deprecated */ @@ -4897,6 +4904,7 @@ declare namespace ts { function isEqualsGreaterThanToken(node: Node): node is EqualsGreaterThanToken; function isIdentifier(node: Node): node is Identifier; function isPrivateIdentifier(node: Node): node is PrivateIdentifier; + function isModuleExportName(node: Node): node is ModuleExportName; function isAssertsKeyword(node: Node): node is AssertsKeyword; function isAwaitKeyword(node: Node): node is AwaitKeyword; function isQualifiedName(node: Node): node is QualifiedName; diff --git a/tests/baselines/reference/goToDefinitionImportedNames12.baseline.jsonc b/tests/baselines/reference/goToDefinitionImportedNames12.baseline.jsonc new file mode 100644 index 0000000000000..7553c9dd0acf9 --- /dev/null +++ b/tests/baselines/reference/goToDefinitionImportedNames12.baseline.jsonc @@ -0,0 +1,103 @@ +// === goToDefinition === +// === /tests/cases/fourslash/a.ts === +// <|const [|a|] = 1;|> +// export { a as " b " }; + +// === /tests/cases/fourslash/e.ts === +// import { c } from "./d"; +// /*GOTO DEF*/[|c|]; + + // === Details === + [ + { + "kind": "const", + "name": "a", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /tests/cases/fourslash/a.ts === +// <|const [|a|] = 1;|> +// export { a as " b " }; + +// === /tests/cases/fourslash/c.ts === +// export { /*GOTO DEF*/[|" b "|] as c } from "./b"; + + // === Details === + [ + { + "kind": "const", + "name": "a", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /tests/cases/fourslash/a.ts === +// <|const [|a|] = 1;|> +// export { a as " b " }; + +// === /tests/cases/fourslash/c.ts === +// export { " b " as /*GOTO DEF*/[|c|] } from "./b"; + + // === Details === + [ + { + "kind": "const", + "name": "a", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /tests/cases/fourslash/a.ts === +// <|const [|a|] = 1;|> +// export { /*GOTO DEF*/a as " b " }; + + // === Details === + [ + { + "kind": "const", + "name": "a", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false, + "failedAliasResolution": false + } + ] + + + +// === goToDefinition === +// === /tests/cases/fourslash/a.ts === +// <|const [|a|] = 1;|> +// export { a as /*GOTO DEF*/" b " }; + + // === Details === + [ + { + "kind": "const", + "name": "a", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionImportedNames12.ts b/tests/cases/fourslash/goToDefinitionImportedNames12.ts new file mode 100644 index 0000000000000..06aad211cd22c --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionImportedNames12.ts @@ -0,0 +1,24 @@ +/// + +// @Filename: e.ts +//// import { c } from "./d"; +//// /*ref1*/c; + + +// @Filename: d.ts +////export * from "./c"; + + +// @Filename: c.ts +////export { /*ref2*/" b " as /*ref3*/c } from "./b"; + + +// @Filename: b.ts +////export * from "./a"; + + +// @Filename: a.ts +////const a = /*varDefinition*/1; +////export { /*ref4*/a as /*ref5*/" b " }; + +verify.baselineGoToDefinition('ref1', 'ref2', 'ref3', 'ref4', 'ref5') From 607f4b3f243846b3bfd2682cf1510d703dee8b8b Mon Sep 17 00:00:00 2001 From: Jack Works Date: Wed, 14 Jun 2023 11:44:29 +0800 Subject: [PATCH 3/6] Improve error message for import { a as "x" } --- src/compiler/diagnosticMessages.json | 6 +++++- src/compiler/parser.ts | 11 ++++++++-- .../reference/es2022stringExportBasic.js | 14 +++++++++++++ .../reference/es2022stringExportBasic.symbols | 17 ++++++++++++++++ .../reference/es2022stringExportBasic.types | 17 ++++++++++++++++ .../es2022stringExportError.errors.txt | 18 +++++++++++++++++ .../reference/es2022stringExportError.js | 20 +++++++++++++++++++ .../reference/es2022stringExportError.symbols | 17 ++++++++++++++++ .../reference/es2022stringExportError.types | 18 +++++++++++++++++ ...EscapesInNames02(target=es2015).errors.txt | 5 ++++- .../cases/compiler/es2022stringExportBasic.ts | 8 ++++++++ .../cases/compiler/es2022stringExportError.ts | 10 ++++++++++ 12 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/es2022stringExportBasic.js create mode 100644 tests/baselines/reference/es2022stringExportBasic.symbols create mode 100644 tests/baselines/reference/es2022stringExportBasic.types create mode 100644 tests/baselines/reference/es2022stringExportError.errors.txt create mode 100644 tests/baselines/reference/es2022stringExportError.js create mode 100644 tests/baselines/reference/es2022stringExportError.symbols create mode 100644 tests/baselines/reference/es2022stringExportError.types create mode 100644 tests/cases/compiler/es2022stringExportBasic.ts create mode 100644 tests/cases/compiler/es2022stringExportError.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index be9b967e92810..eb9658a5804bf 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1663,10 +1663,14 @@ "category": "Message", "code": 2212 }, - "String literal module export names must be followed by a 'from' clause.": { + "Imported name can only be an Identifier": { "category": "Error", "code": 2213 }, + "String literal module export names must be followed by a 'from' clause.": { + "category": "Error", + "code": 2214 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 068a90601fcd2..3edf55d8945bd 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -8456,8 +8456,15 @@ namespace Parser { checkIdentifierEnd = scanner.getTokenEnd(); return parseIdentifierName(); } - function parseModuleExportNameOnlyForExports() { - if (kind === SyntaxKind.ImportSpecifier) return parseNameWithKeywordCheck(); + function parseModuleExportNameOnlyForExports(): ModuleExportName { + if (kind === SyntaxKind.ImportSpecifier) { + if (token() !== SyntaxKind.Identifier && !isKeyword(token())) { + const node = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics.Imported_name_can_only_be_an_Identifier); + nextToken(); + return node; + } + return parseNameWithKeywordCheck(); + } return parseModuleExportName(parseNameWithKeywordCheck); } function parseModuleExportName(parser: () => Identifier): ModuleExportName { diff --git a/tests/baselines/reference/es2022stringExportBasic.js b/tests/baselines/reference/es2022stringExportBasic.js new file mode 100644 index 0000000000000..5693a5fe51a73 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportBasic.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/es2022stringExportBasic.ts] //// + +//// [lib.d.ts] +declare const item: string; +export { item as "non-ident" }; + +//// [app.ts] +import { "non-ident" as str } from "./lib" +str + + +//// [app.js] +import { "non-ident" as str } from "./lib"; +str; diff --git a/tests/baselines/reference/es2022stringExportBasic.symbols b/tests/baselines/reference/es2022stringExportBasic.symbols new file mode 100644 index 0000000000000..438610f00e760 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportBasic.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/es2022stringExportBasic.ts] //// + +=== lib.d.ts === +declare const item: string; +>item : Symbol(item, Decl(lib.d.ts, --, --)) + +export { item as "non-ident" }; +>item : Symbol(item, Decl(lib.d.ts, --, --)) +>"non-ident" : Symbol("non-ident", Decl(lib.d.ts, --, --)) + +=== app.ts === +import { "non-ident" as str } from "./lib" +>str : Symbol(str, Decl(app.ts, 0, 8)) + +str +>str : Symbol(str, Decl(app.ts, 0, 8)) + diff --git a/tests/baselines/reference/es2022stringExportBasic.types b/tests/baselines/reference/es2022stringExportBasic.types new file mode 100644 index 0000000000000..c054dc3b09fa2 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportBasic.types @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/es2022stringExportBasic.ts] //// + +=== lib.d.ts === +declare const item: string; +>item : string + +export { item as "non-ident" }; +>item : string +>"non-ident" : string + +=== app.ts === +import { "non-ident" as str } from "./lib" +>str : string + +str +>str : string + diff --git a/tests/baselines/reference/es2022stringExportError.errors.txt b/tests/baselines/reference/es2022stringExportError.errors.txt new file mode 100644 index 0000000000000..3aae67e1b78af --- /dev/null +++ b/tests/baselines/reference/es2022stringExportError.errors.txt @@ -0,0 +1,18 @@ +index.ts(1,10): error TS2214: String literal module export names must be followed by a 'from' clause. +index2.ts(1,17): error TS2213: Imported name can only be an Identifier + + +==== mod.ts (0 errors) ==== + const a = 1; + export { a } + +==== index.ts (1 errors) ==== + export { "non-ident" }; + ~~~~~~~~~~~ +!!! error TS2214: String literal module export names must be followed by a 'from' clause. + +==== index2.ts (1 errors) ==== + import { "a" as "b" } from "./mod"; + ~~~ +!!! error TS2213: Imported name can only be an Identifier + \ No newline at end of file diff --git a/tests/baselines/reference/es2022stringExportError.js b/tests/baselines/reference/es2022stringExportError.js new file mode 100644 index 0000000000000..277c920f07263 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportError.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/es2022stringExportError.ts] //// + +//// [mod.ts] +const a = 1; +export { a } + +//// [index.ts] +export { "non-ident" }; + +//// [index2.ts] +import { "a" as "b" } from "./mod"; + + +//// [mod.js] +var a = 1; +export { a }; +//// [index.js] +export { "non-ident" }; +//// [index2.js] +export {}; diff --git a/tests/baselines/reference/es2022stringExportError.symbols b/tests/baselines/reference/es2022stringExportError.symbols new file mode 100644 index 0000000000000..774ce8573efb7 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportError.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/es2022stringExportError.ts] //// + +=== mod.ts === +const a = 1; +>a : Symbol(a, Decl(mod.ts, 0, 5)) + +export { a } +>a : Symbol(a, Decl(mod.ts, 1, 8)) + +=== index.ts === +export { "non-ident" }; +>"non-ident" : Symbol("non-ident", Decl(index.ts, 0, 8)) + +=== index2.ts === +import { "a" as "b" } from "./mod"; +> : Symbol((Missing), Decl(index2.ts, 0, 8)) + diff --git a/tests/baselines/reference/es2022stringExportError.types b/tests/baselines/reference/es2022stringExportError.types new file mode 100644 index 0000000000000..7db406faee2be --- /dev/null +++ b/tests/baselines/reference/es2022stringExportError.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/es2022stringExportError.ts] //// + +=== mod.ts === +const a = 1; +>a : 1 +>1 : 1 + +export { a } +>a : 1 + +=== index.ts === +export { "non-ident" }; +>"non-ident" : any + +=== index2.ts === +import { "a" as "b" } from "./mod"; +> : 1 + diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es2015).errors.txt b/tests/baselines/reference/unicodeEscapesInNames02(target=es2015).errors.txt index 2b476471c81cd..ba2db3d65e30b 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es2015).errors.txt +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es2015).errors.txt @@ -1,4 +1,5 @@ astralAsSurrogatePair.ts(1,17): error TS1127: Invalid character. +astralAsSurrogatePair.ts(1,18): error TS1005: ',' expected. astralAsSurrogatePair.ts(1,18): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uD800'. astralAsSurrogatePair.ts(1,23): error TS1127: Invalid character. astralAsSurrogatePair.ts(1,24): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uDEA7'. @@ -33,11 +34,13 @@ astralAsSurrogatePair.ts(1,24): error TS2305: Module '"./extendedEscapesForAstra _\u{102A7} += "!"; -==== astralAsSurrogatePair.ts (4 errors) ==== +==== astralAsSurrogatePair.ts (5 errors) ==== import { _𐊧 as \uD800\uDEA7 } from "./extendedEscapesForAstralsInVarsAndClasses.js"; !!! error TS1127: Invalid character. ~~~~~ +!!! error TS1005: ',' expected. + ~~~~~ !!! error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uD800'. !!! error TS1127: Invalid character. diff --git a/tests/cases/compiler/es2022stringExportBasic.ts b/tests/cases/compiler/es2022stringExportBasic.ts new file mode 100644 index 0000000000000..18c78c78219e7 --- /dev/null +++ b/tests/cases/compiler/es2022stringExportBasic.ts @@ -0,0 +1,8 @@ +// @module: esnext +// @filename: lib.d.ts +declare const item: string; +export { item as "non-ident" }; + +// @filename: app.ts +import { "non-ident" as str } from "./lib" +str diff --git a/tests/cases/compiler/es2022stringExportError.ts b/tests/cases/compiler/es2022stringExportError.ts new file mode 100644 index 0000000000000..93de2b8d49bdb --- /dev/null +++ b/tests/cases/compiler/es2022stringExportError.ts @@ -0,0 +1,10 @@ +// @module: esnext +// @filename: mod.ts +const a = 1; +export { a } + +// @filename: index.ts +export { "non-ident" }; + +// @filename: index2.ts +import { "a" as "b" } from "./mod"; From cda782541186dbd8eda850ba782255c9d72afe01 Mon Sep 17 00:00:00 2001 From: Jack Works Date: Wed, 14 Jun 2023 16:31:32 +0800 Subject: [PATCH 4/6] Fix CommonJS AMD UMD emit --- src/compiler/factory/nodeFactory.ts | 32 +++++++--- src/compiler/types.ts | 6 +- .../reference/es2022stringExportEmit_amd.js | 43 +++++++++++++ .../es2022stringExportEmit_amd.symbols | 51 ++++++++++++++++ .../es2022stringExportEmit_amd.types | 55 +++++++++++++++++ .../es2022stringExportEmit_commonjs.js | 41 +++++++++++++ .../es2022stringExportEmit_commonjs.symbols | 51 ++++++++++++++++ .../es2022stringExportEmit_commonjs.types | 55 +++++++++++++++++ .../es2022stringExportEmit_es2015.errors.txt | 31 ++++++++++ .../es2022stringExportEmit_es2015.js | 30 +++++++++ .../es2022stringExportEmit_es2015.symbols | 51 ++++++++++++++++ .../es2022stringExportEmit_es2015.types | 55 +++++++++++++++++ .../es2022stringExportEmit_es2020.errors.txt | 31 ++++++++++ .../es2022stringExportEmit_es2020.js | 30 +++++++++ .../es2022stringExportEmit_es2020.symbols | 51 ++++++++++++++++ .../es2022stringExportEmit_es2020.types | 55 +++++++++++++++++ .../es2022stringExportEmit_es2022.js | 29 +++++++++ .../es2022stringExportEmit_es2022.symbols | 51 ++++++++++++++++ .../es2022stringExportEmit_es2022.types | 55 +++++++++++++++++ .../es2022stringExportEmit_system.js | 59 ++++++++++++++++++ .../es2022stringExportEmit_system.symbols | 51 ++++++++++++++++ .../es2022stringExportEmit_system.types | 55 +++++++++++++++++ .../reference/es2022stringExportEmit_umd.js | 61 +++++++++++++++++++ .../es2022stringExportEmit_umd.symbols | 51 ++++++++++++++++ .../es2022stringExportEmit_umd.types | 55 +++++++++++++++++ .../compiler/es2022stringExportEmit_amd.ts | 18 ++++++ .../es2022stringExportEmit_commonjs.ts | 18 ++++++ .../compiler/es2022stringExportEmit_es2015.ts | 18 ++++++ .../compiler/es2022stringExportEmit_es2020.ts | 18 ++++++ .../compiler/es2022stringExportEmit_es2022.ts | 18 ++++++ .../compiler/es2022stringExportEmit_system.ts | 18 ++++++ .../compiler/es2022stringExportEmit_umd.ts | 18 ++++++ 32 files changed, 1248 insertions(+), 13 deletions(-) create mode 100644 tests/baselines/reference/es2022stringExportEmit_amd.js create mode 100644 tests/baselines/reference/es2022stringExportEmit_amd.symbols create mode 100644 tests/baselines/reference/es2022stringExportEmit_amd.types create mode 100644 tests/baselines/reference/es2022stringExportEmit_commonjs.js create mode 100644 tests/baselines/reference/es2022stringExportEmit_commonjs.symbols create mode 100644 tests/baselines/reference/es2022stringExportEmit_commonjs.types create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2015.errors.txt create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2015.js create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2015.symbols create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2015.types create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2020.errors.txt create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2020.js create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2020.symbols create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2020.types create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2022.js create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2022.symbols create mode 100644 tests/baselines/reference/es2022stringExportEmit_es2022.types create mode 100644 tests/baselines/reference/es2022stringExportEmit_system.js create mode 100644 tests/baselines/reference/es2022stringExportEmit_system.symbols create mode 100644 tests/baselines/reference/es2022stringExportEmit_system.types create mode 100644 tests/baselines/reference/es2022stringExportEmit_umd.js create mode 100644 tests/baselines/reference/es2022stringExportEmit_umd.symbols create mode 100644 tests/baselines/reference/es2022stringExportEmit_umd.types create mode 100644 tests/cases/compiler/es2022stringExportEmit_amd.ts create mode 100644 tests/cases/compiler/es2022stringExportEmit_commonjs.ts create mode 100644 tests/cases/compiler/es2022stringExportEmit_es2015.ts create mode 100644 tests/cases/compiler/es2022stringExportEmit_es2020.ts create mode 100644 tests/cases/compiler/es2022stringExportEmit_es2022.ts create mode 100644 tests/cases/compiler/es2022stringExportEmit_system.ts create mode 100644 tests/cases/compiler/es2022stringExportEmit_umd.ts diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index dfa1e16505bb1..9b84d0c687dde 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -1,5 +1,6 @@ import { __String, + AccessExpression, addRange, append, appendIfUnique, @@ -61,6 +62,7 @@ import { containsObjectRestOrSpread, ContinueStatement, createBaseNodeFactory, + createElementAccessOrPropertyAccessExpression, createNodeConverters, createParenthesizerRules, createScanner, @@ -188,6 +190,7 @@ import { isMethodDeclaration, isMethodSignature, isModuleDeclaration, + isModuleExportName, isNamedDeclaration, isNodeArray, isNodeKind, @@ -6658,9 +6661,10 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode : reduceLeft(expressions, factory.createComma)!; } - function getName(node: Declaration | undefined, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags: EmitFlags = 0, ignoreAssignedName?: boolean) { + function getName(node: Declaration | undefined, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags: EmitFlags = 0, ignoreAssignedName?: boolean): Identifier | ModuleExportName { const nodeName = ignoreAssignedName ? node && getNonAssignedNameOfDeclaration(node) : getNameOfDeclaration(node); - if (nodeName && isIdentifier(nodeName) && !isGeneratedIdentifier(nodeName)) { + // ModuleExportName includes Identifier + if (nodeName && isModuleExportName(nodeName) && !isGeneratedIdentifier(nodeName)) { // TODO(rbuckton): Does this need to be parented? const name = setParent(setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= getEmitFlags(nodeName); @@ -6684,7 +6688,9 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean) { - return getName(node, allowComments, allowSourceMaps, EmitFlags.LocalName | EmitFlags.InternalName); + const name = getName(node, allowComments, allowSourceMaps, EmitFlags.LocalName | EmitFlags.InternalName); + Debug.assertNode(name, isIdentifier); + return name; } /** @@ -6699,7 +6705,9 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode * @param ignoreAssignedName Indicates that the assigned name of a declaration shouldn't be considered. */ function getLocalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean, ignoreAssignedName?: boolean) { - return getName(node, allowComments, allowSourceMaps, EmitFlags.LocalName, ignoreAssignedName); + const name = getName(node, allowComments, allowSourceMaps, EmitFlags.LocalName, ignoreAssignedName); + Debug.assertNode(name, isIdentifier); + return name; } /** @@ -6712,7 +6720,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode * @param allowComments A value indicating whether comments may be emitted for the name. * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ - function getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier { + function getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | ModuleExportName { return getName(node, allowComments, allowSourceMaps, EmitFlags.ExportName); } @@ -6724,7 +6732,9 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getDeclarationName(node: Declaration | undefined, allowComments?: boolean, allowSourceMaps?: boolean) { - return getName(node, allowComments, allowSourceMaps); + const name = getName(node, allowComments, allowSourceMaps); + Debug.assertNode(name, isIdentifier); + return name; } /** @@ -6735,8 +6745,8 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode * @param allowComments A value indicating whether comments may be emitted for the name. * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ - function getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression { - const qualifiedName = createPropertyAccessExpression(ns, nodeIsSynthesized(name) ? name : cloneNode(name)); + function getNamespaceMemberName(ns: Identifier, name: ModuleExportName, allowComments?: boolean, allowSourceMaps?: boolean): AccessExpression { + const qualifiedName = createElementAccessOrPropertyAccessExpression(ns, nodeIsSynthesized(name) ? name : cloneNode(name)); setTextRange(qualifiedName, name); let emitFlags: EmitFlags = 0; if (!allowSourceMaps) emitFlags |= EmitFlags.NoSourceMap; @@ -6756,11 +6766,13 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode * @param allowComments A value indicating whether comments may be emitted for the name. * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ - function getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression { + function getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | AccessExpression { if (ns && hasSyntacticModifier(node, ModifierFlags.Export)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } - return getExportName(node, allowComments, allowSourceMaps); + const name = getExportName(node, allowComments, allowSourceMaps); + Debug.assertNode(name, isIdentifier); + return name; } /** diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7fa3678454acd..804922735bfb6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -8963,7 +8963,7 @@ export interface NodeFactory { * * @internal */ - getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; + getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | ModuleExportName; /** * Gets the name of a declaration for use in declarations. * @@ -8984,7 +8984,7 @@ export interface NodeFactory { * * @internal */ - getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression; + getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): AccessExpression; /** * Gets the exported name of a declaration for use in expressions. * @@ -8998,7 +8998,7 @@ export interface NodeFactory { * * @internal */ - getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression; + getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | AccessExpression; // // Utilities diff --git a/tests/baselines/reference/es2022stringExportEmit_amd.js b/tests/baselines/reference/es2022stringExportEmit_amd.js new file mode 100644 index 0000000000000..6abc5fe9f8c23 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_amd.js @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/es2022stringExportEmit_amd.ts] //// + +//// [mod.ts] +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +//// [index.ts] +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' + + +//// [mod.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports[" \"hello\" "] = exports["y"] = exports.x = void 0; + exports.x = 1; + exports["y"] = exports.x; + exports[" \"hello\" "] = exports.x; + exports[" \"hello\" "] = exports["y"] = exports.x = 2; +}); +//// [index.js] +define(["require", "exports", "./mod", "./mod", "./mod"], function (require, exports, mod_1, _a, mod_2) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Hello = exports[" reexport x2 "] = exports[" reexport x "] = exports.y2 = exports.y = exports[" mod "] = void 0; + console.log(mod_1.y, mod_1[" \"hello\" "]); + exports[" mod "] = _a; + Object.defineProperty(exports, "y", { enumerable: true, get: function () { return mod_2.x; } }); + Object.defineProperty(exports, "y2", { enumerable: true, get: function () { return mod_2.y; } }); + Object.defineProperty(exports, " reexport x ", { enumerable: true, get: function () { return mod_2.x; } }); + Object.defineProperty(exports, " reexport x2 ", { enumerable: true, get: function () { return mod_2["x"]; } }); + Object.defineProperty(exports, "Hello", { enumerable: true, get: function () { return mod_2[' "hello" ']; } }); +}); diff --git a/tests/baselines/reference/es2022stringExportEmit_amd.symbols b/tests/baselines/reference/es2022stringExportEmit_amd.symbols new file mode 100644 index 0000000000000..546ac99412c4c --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_amd.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/es2022stringExportEmit_amd.ts] //// + +=== mod.ts === +export let x = 1; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +x = 2; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +export { x as "y", x as ' "hello" ' } +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>"y" : Symbol("y", Decl(mod.ts, 2, 8)) +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>' "hello" ' : Symbol(' "hello" ', Decl(mod.ts, 2, 18)) + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +console.log(y, Hello) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +export * as " mod " from "./mod" +>" mod " : Symbol(" mod ", Decl(index.ts, 2, 6)) + +export { + x as y, +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>y : Symbol(y, Decl(index.ts, 3, 8)) + + y as y2, +>y : Symbol("y", Decl(mod.ts, 2, 8)) +>y2 : Symbol(y2, Decl(index.ts, 4, 11)) + + x as " reexport x ", +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>" reexport x " : Symbol(" reexport x ", Decl(index.ts, 5, 12)) + + "x" as " reexport x2 ", +>" reexport x2 " : Symbol(" reexport x2 ", Decl(index.ts, 6, 24)) + + ' "hello" ' as Hello +>Hello : Symbol(Hello, Decl(index.ts, 7, 27)) + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_amd.types b/tests/baselines/reference/es2022stringExportEmit_amd.types new file mode 100644 index 0000000000000..7a7f9ea4eb70d --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_amd.types @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/es2022stringExportEmit_amd.ts] //// + +=== mod.ts === +export let x = 1; +>x : number +>1 : 1 + +x = 2; +>x = 2 : 2 +>x : number +>2 : 2 + +export { x as "y", x as ' "hello" ' } +>x : number +>"y" : number +>x : number +>' "hello" ' : number + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : number +>Hello : number + +console.log(y, Hello) +>console.log(y, Hello) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>y : number +>Hello : number + +export * as " mod " from "./mod" +>" mod " : typeof import("mod") + +export { + x as y, +>x : number +>y : number + + y as y2, +>y : number +>y2 : number + + x as " reexport x ", +>x : number +>" reexport x " : number + + "x" as " reexport x2 ", +>" reexport x2 " : number + + ' "hello" ' as Hello +>Hello : number + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_commonjs.js b/tests/baselines/reference/es2022stringExportEmit_commonjs.js new file mode 100644 index 0000000000000..af306447c131e --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_commonjs.js @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/es2022stringExportEmit_commonjs.ts] //// + +//// [mod.ts] +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +//// [index.ts] +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' + + +//// [mod.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports[" \"hello\" "] = exports["y"] = exports.x = void 0; +exports.x = 1; +exports["y"] = exports.x; +exports[" \"hello\" "] = exports.x; +exports[" \"hello\" "] = exports["y"] = exports.x = 2; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Hello = exports[" reexport x2 "] = exports[" reexport x "] = exports.y2 = exports.y = exports[" mod "] = void 0; +var mod_1 = require("./mod"); +console.log(mod_1.y, mod_1[" \"hello\" "]); +exports[" mod "] = require("./mod"); +var mod_2 = require("./mod"); +Object.defineProperty(exports, "y", { enumerable: true, get: function () { return mod_2.x; } }); +Object.defineProperty(exports, "y2", { enumerable: true, get: function () { return mod_2.y; } }); +Object.defineProperty(exports, " reexport x ", { enumerable: true, get: function () { return mod_2.x; } }); +Object.defineProperty(exports, " reexport x2 ", { enumerable: true, get: function () { return mod_2["x"]; } }); +Object.defineProperty(exports, "Hello", { enumerable: true, get: function () { return mod_2[' "hello" ']; } }); diff --git a/tests/baselines/reference/es2022stringExportEmit_commonjs.symbols b/tests/baselines/reference/es2022stringExportEmit_commonjs.symbols new file mode 100644 index 0000000000000..5ab2c68c283c1 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_commonjs.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/es2022stringExportEmit_commonjs.ts] //// + +=== mod.ts === +export let x = 1; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +x = 2; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +export { x as "y", x as ' "hello" ' } +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>"y" : Symbol("y", Decl(mod.ts, 2, 8)) +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>' "hello" ' : Symbol(' "hello" ', Decl(mod.ts, 2, 18)) + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +console.log(y, Hello) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +export * as " mod " from "./mod" +>" mod " : Symbol(" mod ", Decl(index.ts, 2, 6)) + +export { + x as y, +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>y : Symbol(y, Decl(index.ts, 3, 8)) + + y as y2, +>y : Symbol("y", Decl(mod.ts, 2, 8)) +>y2 : Symbol(y2, Decl(index.ts, 4, 11)) + + x as " reexport x ", +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>" reexport x " : Symbol(" reexport x ", Decl(index.ts, 5, 12)) + + "x" as " reexport x2 ", +>" reexport x2 " : Symbol(" reexport x2 ", Decl(index.ts, 6, 24)) + + ' "hello" ' as Hello +>Hello : Symbol(Hello, Decl(index.ts, 7, 27)) + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_commonjs.types b/tests/baselines/reference/es2022stringExportEmit_commonjs.types new file mode 100644 index 0000000000000..235bb03056da4 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_commonjs.types @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/es2022stringExportEmit_commonjs.ts] //// + +=== mod.ts === +export let x = 1; +>x : number +>1 : 1 + +x = 2; +>x = 2 : 2 +>x : number +>2 : 2 + +export { x as "y", x as ' "hello" ' } +>x : number +>"y" : number +>x : number +>' "hello" ' : number + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : number +>Hello : number + +console.log(y, Hello) +>console.log(y, Hello) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>y : number +>Hello : number + +export * as " mod " from "./mod" +>" mod " : typeof import("mod") + +export { + x as y, +>x : number +>y : number + + y as y2, +>y : number +>y2 : number + + x as " reexport x ", +>x : number +>" reexport x " : number + + "x" as " reexport x2 ", +>" reexport x2 " : number + + ' "hello" ' as Hello +>Hello : number + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_es2015.errors.txt b/tests/baselines/reference/es2022stringExportEmit_es2015.errors.txt new file mode 100644 index 0000000000000..93f08f676ddf7 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2015.errors.txt @@ -0,0 +1,31 @@ +index.ts(1,13): error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. +index.ts(3,13): error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. +index.ts(7,10): error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. +mod.ts(3,25): error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + + +==== mod.ts (1 errors) ==== + export let x = 1; + x = 2; + export { x as "y", x as ' "hello" ' } + ~~~~~~~~~~~ +!!! error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + +==== index.ts (3 errors) ==== + import { y, ' "hello" ' as Hello } from './mod' + ~~~~~~~~~~~ +!!! error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + console.log(y, Hello) + export * as " mod " from "./mod" + ~~~~~~~ +!!! error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + export { + x as y, + y as y2, + x as " reexport x ", + ~~~~~~~~~~~~~~ +!!! error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + "x" as " reexport x2 ", + ' "hello" ' as Hello + } from './mod' + \ No newline at end of file diff --git a/tests/baselines/reference/es2022stringExportEmit_es2015.js b/tests/baselines/reference/es2022stringExportEmit_es2015.js new file mode 100644 index 0000000000000..1678499986f7c --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2015.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/es2022stringExportEmit_es2015.ts] //// + +//// [mod.ts] +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +//// [index.ts] +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' + + +//// [mod.js] +export var x = 1; +x = 2; +export { x as y }; +//// [index.js] +const Hello = mod_1[' "hello" ']; +import { y } from './mod'; +import * as mod_1 from './mod'; +console.log(y, Hello); +export { x as y, y as y2 } from './mod'; diff --git a/tests/baselines/reference/es2022stringExportEmit_es2015.symbols b/tests/baselines/reference/es2022stringExportEmit_es2015.symbols new file mode 100644 index 0000000000000..729a41b63a85a --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2015.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/es2022stringExportEmit_es2015.ts] //// + +=== mod.ts === +export let x = 1; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +x = 2; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +export { x as "y", x as ' "hello" ' } +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>"y" : Symbol("y", Decl(mod.ts, 2, 8)) +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>' "hello" ' : Symbol(' "hello" ', Decl(mod.ts, 2, 18)) + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +console.log(y, Hello) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +export * as " mod " from "./mod" +>" mod " : Symbol(" mod ", Decl(index.ts, 2, 6)) + +export { + x as y, +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>y : Symbol(y, Decl(index.ts, 3, 8)) + + y as y2, +>y : Symbol("y", Decl(mod.ts, 2, 8)) +>y2 : Symbol(y2, Decl(index.ts, 4, 11)) + + x as " reexport x ", +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>" reexport x " : Symbol(" reexport x ", Decl(index.ts, 5, 12)) + + "x" as " reexport x2 ", +>" reexport x2 " : Symbol(" reexport x2 ", Decl(index.ts, 6, 24)) + + ' "hello" ' as Hello +>Hello : Symbol(Hello, Decl(index.ts, 7, 27)) + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_es2015.types b/tests/baselines/reference/es2022stringExportEmit_es2015.types new file mode 100644 index 0000000000000..694aed87b9e6f --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2015.types @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/es2022stringExportEmit_es2015.ts] //// + +=== mod.ts === +export let x = 1; +>x : number +>1 : 1 + +x = 2; +>x = 2 : 2 +>x : number +>2 : 2 + +export { x as "y", x as ' "hello" ' } +>x : number +>"y" : number +>x : number +>' "hello" ' : number + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : number +>Hello : number + +console.log(y, Hello) +>console.log(y, Hello) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>y : number +>Hello : number + +export * as " mod " from "./mod" +>" mod " : typeof import("mod") + +export { + x as y, +>x : number +>y : number + + y as y2, +>y : number +>y2 : number + + x as " reexport x ", +>x : number +>" reexport x " : number + + "x" as " reexport x2 ", +>" reexport x2 " : number + + ' "hello" ' as Hello +>Hello : number + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_es2020.errors.txt b/tests/baselines/reference/es2022stringExportEmit_es2020.errors.txt new file mode 100644 index 0000000000000..93f08f676ddf7 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2020.errors.txt @@ -0,0 +1,31 @@ +index.ts(1,13): error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. +index.ts(3,13): error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. +index.ts(7,10): error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. +mod.ts(3,25): error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + + +==== mod.ts (1 errors) ==== + export let x = 1; + x = 2; + export { x as "y", x as ' "hello" ' } + ~~~~~~~~~~~ +!!! error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + +==== index.ts (3 errors) ==== + import { y, ' "hello" ' as Hello } from './mod' + ~~~~~~~~~~~ +!!! error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + console.log(y, Hello) + export * as " mod " from "./mod" + ~~~~~~~ +!!! error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + export { + x as y, + y as y2, + x as " reexport x ", + ~~~~~~~~~~~~~~ +!!! error TS1491: String literal module export names are not allowed when the 'module' option is set to 'es2020' or lower. + "x" as " reexport x2 ", + ' "hello" ' as Hello + } from './mod' + \ No newline at end of file diff --git a/tests/baselines/reference/es2022stringExportEmit_es2020.js b/tests/baselines/reference/es2022stringExportEmit_es2020.js new file mode 100644 index 0000000000000..26651f293aa88 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2020.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/es2022stringExportEmit_es2020.ts] //// + +//// [mod.ts] +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +//// [index.ts] +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' + + +//// [mod.js] +export var x = 1; +x = 2; +export { x as y }; +//// [index.js] +const Hello = mod_1[' "hello" ']; +import { y } from './mod'; +import * as mod_1 from './mod'; +console.log(y, Hello); +export { x as y, y as y2 } from './mod'; diff --git a/tests/baselines/reference/es2022stringExportEmit_es2020.symbols b/tests/baselines/reference/es2022stringExportEmit_es2020.symbols new file mode 100644 index 0000000000000..3e6ba45fbd69c --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2020.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/es2022stringExportEmit_es2020.ts] //// + +=== mod.ts === +export let x = 1; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +x = 2; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +export { x as "y", x as ' "hello" ' } +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>"y" : Symbol("y", Decl(mod.ts, 2, 8)) +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>' "hello" ' : Symbol(' "hello" ', Decl(mod.ts, 2, 18)) + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +console.log(y, Hello) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +export * as " mod " from "./mod" +>" mod " : Symbol(" mod ", Decl(index.ts, 2, 6)) + +export { + x as y, +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>y : Symbol(y, Decl(index.ts, 3, 8)) + + y as y2, +>y : Symbol("y", Decl(mod.ts, 2, 8)) +>y2 : Symbol(y2, Decl(index.ts, 4, 11)) + + x as " reexport x ", +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>" reexport x " : Symbol(" reexport x ", Decl(index.ts, 5, 12)) + + "x" as " reexport x2 ", +>" reexport x2 " : Symbol(" reexport x2 ", Decl(index.ts, 6, 24)) + + ' "hello" ' as Hello +>Hello : Symbol(Hello, Decl(index.ts, 7, 27)) + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_es2020.types b/tests/baselines/reference/es2022stringExportEmit_es2020.types new file mode 100644 index 0000000000000..083de5854efd0 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2020.types @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/es2022stringExportEmit_es2020.ts] //// + +=== mod.ts === +export let x = 1; +>x : number +>1 : 1 + +x = 2; +>x = 2 : 2 +>x : number +>2 : 2 + +export { x as "y", x as ' "hello" ' } +>x : number +>"y" : number +>x : number +>' "hello" ' : number + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : number +>Hello : number + +console.log(y, Hello) +>console.log(y, Hello) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>y : number +>Hello : number + +export * as " mod " from "./mod" +>" mod " : typeof import("mod") + +export { + x as y, +>x : number +>y : number + + y as y2, +>y : number +>y2 : number + + x as " reexport x ", +>x : number +>" reexport x " : number + + "x" as " reexport x2 ", +>" reexport x2 " : number + + ' "hello" ' as Hello +>Hello : number + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_es2022.js b/tests/baselines/reference/es2022stringExportEmit_es2022.js new file mode 100644 index 0000000000000..67b4dbf400900 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2022.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/es2022stringExportEmit_es2022.ts] //// + +//// [mod.ts] +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +//// [index.ts] +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' + + +//// [mod.js] +export var x = 1; +x = 2; +export { x as "y", x as ' "hello" ' }; +//// [index.js] +import { y, ' "hello" ' as Hello } from './mod'; +console.log(y, Hello); +export * as " mod " from "./mod"; +export { x as y, y as y2, x as " reexport x ", "x" as " reexport x2 ", ' "hello" ' as Hello } from './mod'; diff --git a/tests/baselines/reference/es2022stringExportEmit_es2022.symbols b/tests/baselines/reference/es2022stringExportEmit_es2022.symbols new file mode 100644 index 0000000000000..a36b78524ddfb --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2022.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/es2022stringExportEmit_es2022.ts] //// + +=== mod.ts === +export let x = 1; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +x = 2; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +export { x as "y", x as ' "hello" ' } +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>"y" : Symbol("y", Decl(mod.ts, 2, 8)) +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>' "hello" ' : Symbol(' "hello" ', Decl(mod.ts, 2, 18)) + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +console.log(y, Hello) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +export * as " mod " from "./mod" +>" mod " : Symbol(" mod ", Decl(index.ts, 2, 6)) + +export { + x as y, +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>y : Symbol(y, Decl(index.ts, 3, 8)) + + y as y2, +>y : Symbol("y", Decl(mod.ts, 2, 8)) +>y2 : Symbol(y2, Decl(index.ts, 4, 11)) + + x as " reexport x ", +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>" reexport x " : Symbol(" reexport x ", Decl(index.ts, 5, 12)) + + "x" as " reexport x2 ", +>" reexport x2 " : Symbol(" reexport x2 ", Decl(index.ts, 6, 24)) + + ' "hello" ' as Hello +>Hello : Symbol(Hello, Decl(index.ts, 7, 27)) + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_es2022.types b/tests/baselines/reference/es2022stringExportEmit_es2022.types new file mode 100644 index 0000000000000..c8e7d8ab8d3c7 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_es2022.types @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/es2022stringExportEmit_es2022.ts] //// + +=== mod.ts === +export let x = 1; +>x : number +>1 : 1 + +x = 2; +>x = 2 : 2 +>x : number +>2 : 2 + +export { x as "y", x as ' "hello" ' } +>x : number +>"y" : number +>x : number +>' "hello" ' : number + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : number +>Hello : number + +console.log(y, Hello) +>console.log(y, Hello) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>y : number +>Hello : number + +export * as " mod " from "./mod" +>" mod " : typeof import("mod") + +export { + x as y, +>x : number +>y : number + + y as y2, +>y : number +>y2 : number + + x as " reexport x ", +>x : number +>" reexport x " : number + + "x" as " reexport x2 ", +>" reexport x2 " : number + + ' "hello" ' as Hello +>Hello : number + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_system.js b/tests/baselines/reference/es2022stringExportEmit_system.js new file mode 100644 index 0000000000000..e026a59925f2e --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_system.js @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/es2022stringExportEmit_system.ts] //// + +//// [mod.ts] +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +//// [index.ts] +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' + + +//// [mod.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var x; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + exports_1("x", x = 1); + exports_1("y", x); + exports_1(' "hello" ', x); + exports_1(' "hello" ', exports_1("y", exports_1("x", x = 2))); + } + }; +}); +//// [index.js] +System.register(["./mod"], function (exports_1, context_1) { + "use strict"; + var mod_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [ + function (mod_1_1) { + mod_1 = mod_1_1; + exports_1(" mod ", mod_1_1); + exports_1({ + "y": mod_1_1["x"], + "y2": mod_1_1["y"], + " reexport x ": mod_1_1["x"], + " reexport x2 ": mod_1_1["x"], + "Hello": mod_1_1[" \"hello\" "] + }); + } + ], + execute: function () { + console.log(mod_1.y, mod_1[" \"hello\" "]); + } + }; +}); diff --git a/tests/baselines/reference/es2022stringExportEmit_system.symbols b/tests/baselines/reference/es2022stringExportEmit_system.symbols new file mode 100644 index 0000000000000..a0d6f424810d8 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_system.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/es2022stringExportEmit_system.ts] //// + +=== mod.ts === +export let x = 1; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +x = 2; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +export { x as "y", x as ' "hello" ' } +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>"y" : Symbol("y", Decl(mod.ts, 2, 8)) +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>' "hello" ' : Symbol(' "hello" ', Decl(mod.ts, 2, 18)) + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +console.log(y, Hello) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +export * as " mod " from "./mod" +>" mod " : Symbol(" mod ", Decl(index.ts, 2, 6)) + +export { + x as y, +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>y : Symbol(y, Decl(index.ts, 3, 8)) + + y as y2, +>y : Symbol("y", Decl(mod.ts, 2, 8)) +>y2 : Symbol(y2, Decl(index.ts, 4, 11)) + + x as " reexport x ", +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>" reexport x " : Symbol(" reexport x ", Decl(index.ts, 5, 12)) + + "x" as " reexport x2 ", +>" reexport x2 " : Symbol(" reexport x2 ", Decl(index.ts, 6, 24)) + + ' "hello" ' as Hello +>Hello : Symbol(Hello, Decl(index.ts, 7, 27)) + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_system.types b/tests/baselines/reference/es2022stringExportEmit_system.types new file mode 100644 index 0000000000000..72715c6ee4136 --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_system.types @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/es2022stringExportEmit_system.ts] //// + +=== mod.ts === +export let x = 1; +>x : number +>1 : 1 + +x = 2; +>x = 2 : 2 +>x : number +>2 : 2 + +export { x as "y", x as ' "hello" ' } +>x : number +>"y" : number +>x : number +>' "hello" ' : number + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : number +>Hello : number + +console.log(y, Hello) +>console.log(y, Hello) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>y : number +>Hello : number + +export * as " mod " from "./mod" +>" mod " : typeof import("mod") + +export { + x as y, +>x : number +>y : number + + y as y2, +>y : number +>y2 : number + + x as " reexport x ", +>x : number +>" reexport x " : number + + "x" as " reexport x2 ", +>" reexport x2 " : number + + ' "hello" ' as Hello +>Hello : number + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_umd.js b/tests/baselines/reference/es2022stringExportEmit_umd.js new file mode 100644 index 0000000000000..599ee934dc63d --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_umd.js @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/es2022stringExportEmit_umd.ts] //// + +//// [mod.ts] +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +//// [index.ts] +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' + + +//// [mod.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"], factory); + } +})(function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports[" \"hello\" "] = exports["y"] = exports.x = void 0; + exports.x = 1; + exports["y"] = exports.x; + exports[" \"hello\" "] = exports.x; + exports[" \"hello\" "] = exports["y"] = exports.x = 2; +}); +//// [index.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", "./mod", "./mod", "./mod"], factory); + } +})(function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Hello = exports[" reexport x2 "] = exports[" reexport x "] = exports.y2 = exports.y = exports[" mod "] = void 0; + var mod_1 = require("./mod"); + console.log(mod_1.y, mod_1[" \"hello\" "]); + exports[" mod "] = require("./mod"); + var mod_2 = require("./mod"); + Object.defineProperty(exports, "y", { enumerable: true, get: function () { return mod_2.x; } }); + Object.defineProperty(exports, "y2", { enumerable: true, get: function () { return mod_2.y; } }); + Object.defineProperty(exports, " reexport x ", { enumerable: true, get: function () { return mod_2.x; } }); + Object.defineProperty(exports, " reexport x2 ", { enumerable: true, get: function () { return mod_2["x"]; } }); + Object.defineProperty(exports, "Hello", { enumerable: true, get: function () { return mod_2[' "hello" ']; } }); +}); diff --git a/tests/baselines/reference/es2022stringExportEmit_umd.symbols b/tests/baselines/reference/es2022stringExportEmit_umd.symbols new file mode 100644 index 0000000000000..75322273d0a9b --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_umd.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/es2022stringExportEmit_umd.ts] //// + +=== mod.ts === +export let x = 1; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +x = 2; +>x : Symbol(x, Decl(mod.ts, 0, 10)) + +export { x as "y", x as ' "hello" ' } +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>"y" : Symbol("y", Decl(mod.ts, 2, 8)) +>x : Symbol(x, Decl(mod.ts, 0, 10)) +>' "hello" ' : Symbol(' "hello" ', Decl(mod.ts, 2, 18)) + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +console.log(y, Hello) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>y : Symbol(y, Decl(index.ts, 0, 8)) +>Hello : Symbol(Hello, Decl(index.ts, 0, 11)) + +export * as " mod " from "./mod" +>" mod " : Symbol(" mod ", Decl(index.ts, 2, 6)) + +export { + x as y, +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>y : Symbol(y, Decl(index.ts, 3, 8)) + + y as y2, +>y : Symbol("y", Decl(mod.ts, 2, 8)) +>y2 : Symbol(y2, Decl(index.ts, 4, 11)) + + x as " reexport x ", +>x : Symbol(y, Decl(mod.ts, 0, 10)) +>" reexport x " : Symbol(" reexport x ", Decl(index.ts, 5, 12)) + + "x" as " reexport x2 ", +>" reexport x2 " : Symbol(" reexport x2 ", Decl(index.ts, 6, 24)) + + ' "hello" ' as Hello +>Hello : Symbol(Hello, Decl(index.ts, 7, 27)) + +} from './mod' + diff --git a/tests/baselines/reference/es2022stringExportEmit_umd.types b/tests/baselines/reference/es2022stringExportEmit_umd.types new file mode 100644 index 0000000000000..e6dd9322fa80b --- /dev/null +++ b/tests/baselines/reference/es2022stringExportEmit_umd.types @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/es2022stringExportEmit_umd.ts] //// + +=== mod.ts === +export let x = 1; +>x : number +>1 : 1 + +x = 2; +>x = 2 : 2 +>x : number +>2 : 2 + +export { x as "y", x as ' "hello" ' } +>x : number +>"y" : number +>x : number +>' "hello" ' : number + +=== index.ts === +import { y, ' "hello" ' as Hello } from './mod' +>y : number +>Hello : number + +console.log(y, Hello) +>console.log(y, Hello) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>y : number +>Hello : number + +export * as " mod " from "./mod" +>" mod " : typeof import("mod") + +export { + x as y, +>x : number +>y : number + + y as y2, +>y : number +>y2 : number + + x as " reexport x ", +>x : number +>" reexport x " : number + + "x" as " reexport x2 ", +>" reexport x2 " : number + + ' "hello" ' as Hello +>Hello : number + +} from './mod' + diff --git a/tests/cases/compiler/es2022stringExportEmit_amd.ts b/tests/cases/compiler/es2022stringExportEmit_amd.ts new file mode 100644 index 0000000000000..2d08bb8dffbf4 --- /dev/null +++ b/tests/cases/compiler/es2022stringExportEmit_amd.ts @@ -0,0 +1,18 @@ +// @module: amd + +// @filename: mod.ts +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +// @filename: index.ts +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' diff --git a/tests/cases/compiler/es2022stringExportEmit_commonjs.ts b/tests/cases/compiler/es2022stringExportEmit_commonjs.ts new file mode 100644 index 0000000000000..42d9722fac783 --- /dev/null +++ b/tests/cases/compiler/es2022stringExportEmit_commonjs.ts @@ -0,0 +1,18 @@ +// @module: CommonJS + +// @filename: mod.ts +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +// @filename: index.ts +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' diff --git a/tests/cases/compiler/es2022stringExportEmit_es2015.ts b/tests/cases/compiler/es2022stringExportEmit_es2015.ts new file mode 100644 index 0000000000000..2817173d4b9b1 --- /dev/null +++ b/tests/cases/compiler/es2022stringExportEmit_es2015.ts @@ -0,0 +1,18 @@ +// @module: ES2015 + +// @filename: mod.ts +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +// @filename: index.ts +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' diff --git a/tests/cases/compiler/es2022stringExportEmit_es2020.ts b/tests/cases/compiler/es2022stringExportEmit_es2020.ts new file mode 100644 index 0000000000000..2f88cd8476092 --- /dev/null +++ b/tests/cases/compiler/es2022stringExportEmit_es2020.ts @@ -0,0 +1,18 @@ +// @module: ES2020 + +// @filename: mod.ts +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +// @filename: index.ts +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' diff --git a/tests/cases/compiler/es2022stringExportEmit_es2022.ts b/tests/cases/compiler/es2022stringExportEmit_es2022.ts new file mode 100644 index 0000000000000..3d6a55e4644a7 --- /dev/null +++ b/tests/cases/compiler/es2022stringExportEmit_es2022.ts @@ -0,0 +1,18 @@ +// @module: ES2022 + +// @filename: mod.ts +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +// @filename: index.ts +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' diff --git a/tests/cases/compiler/es2022stringExportEmit_system.ts b/tests/cases/compiler/es2022stringExportEmit_system.ts new file mode 100644 index 0000000000000..b20af26a3a9c5 --- /dev/null +++ b/tests/cases/compiler/es2022stringExportEmit_system.ts @@ -0,0 +1,18 @@ +// @module: System + +// @filename: mod.ts +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +// @filename: index.ts +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' diff --git a/tests/cases/compiler/es2022stringExportEmit_umd.ts b/tests/cases/compiler/es2022stringExportEmit_umd.ts new file mode 100644 index 0000000000000..700d4cb55da65 --- /dev/null +++ b/tests/cases/compiler/es2022stringExportEmit_umd.ts @@ -0,0 +1,18 @@ +// @module: umd + +// @filename: mod.ts +export let x = 1; +x = 2; +export { x as "y", x as ' "hello" ' } + +// @filename: index.ts +import { y, ' "hello" ' as Hello } from './mod' +console.log(y, Hello) +export * as " mod " from "./mod" +export { + x as y, + y as y2, + x as " reexport x ", + "x" as " reexport x2 ", + ' "hello" ' as Hello +} from './mod' From 1d8622e8b23503b33fd598035d45ce9d9f679515 Mon Sep 17 00:00:00 2001 From: Jack Works Date: Wed, 14 Jun 2023 16:49:18 +0800 Subject: [PATCH 5/6] remove unnecessary comments --- src/compiler/checker.ts | 5 +---- src/compiler/types.ts | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f1b6b117dd859..e49037f42844a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4227,10 +4227,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function reportNonExportedMember(node: Node, name: ModuleExportName, declarationName: string, moduleSymbol: Symbol, moduleName: string): void { - // for import { "ident" as T } we can provide meaningful error message. (ident is defined locally) - // for import { "not ident" as T } we will still look for the locals of the target module symbol, but - // since it's impossible to define a local ident with invalid name, we will use the normal message "Module_0_has_no_exported_member_1" + function reportNonExportedMember(node: Node, name: Identifier | ModuleExportName, declarationName: string, moduleSymbol: Symbol, moduleName: string): void { const localSymbol = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)?.locals?.get(moduleExportNameTextEscaped(name)); const exports = moduleSymbol.exports; if (localSymbol) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 804922735bfb6..e1d4cb10cbf15 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5950,8 +5950,6 @@ export interface ReverseMappedSymbol extends TransientSymbol { links: ReverseMappedSymbolLinks; } -// All names should starts with __, since it's possible to declare an arbitrary symbol name with -// export { ident as "this" } export const enum InternalSymbolName { Call = "__call", // Call signatures Constructor = "__constructor", // Constructor implementations From 77b32bbe650eb26f025da5d1dd7765a0d4badba4 Mon Sep 17 00:00:00 2001 From: Jack Works Date: Fri, 16 Jun 2023 21:34:30 +0800 Subject: [PATCH 6/6] improve import and completion --- src/compiler/utilities.ts | 34 +- src/services/codefixes/importFixes.ts | 35 +- src/services/completions.ts | 43 +- src/services/exportInfoMap.ts | 4 +- .../completionInNamedImportLocation.baseline | 723 ++++ .../completionListInExportClause01.baseline | 1640 ++++++++ .../completionsImport_ambient.baseline | 3537 +++++++++++++++++ .../completionsImport_augmentation.baseline | 3511 ++++++++++++++++ ...mpletionsImport_fromAmbientModule.baseline | 3511 ++++++++++++++++ .../completionInNamedImportLocation.ts | 22 +- .../completionListInExportClause01.ts | 12 +- .../completionListInImportClause04.ts | 3 + .../fourslash/completionsImport_ambient.ts | 40 +- .../completionsImport_augmentation.ts | 26 +- .../completionsImport_fromAmbientModule.ts | 10 +- 15 files changed, 13029 insertions(+), 122 deletions(-) create mode 100644 tests/baselines/reference/completionInNamedImportLocation.baseline create mode 100644 tests/baselines/reference/completionListInExportClause01.baseline create mode 100644 tests/baselines/reference/completionsImport_ambient.baseline create mode 100644 tests/baselines/reference/completionsImport_augmentation.baseline create mode 100644 tests/baselines/reference/completionsImport_fromAmbientModule.baseline diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c462b2c4bd1ca..5b73176bf94e4 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -270,6 +270,7 @@ import { isGetAccessorDeclaration, isHeritageClause, isIdentifier, + isIdentifierPart, isIdentifierStart, isIdentifierText, isImportTypeNode, @@ -1781,14 +1782,12 @@ export function isAmbientModule(node: Node): node is AmbientModuleDeclaration { } /** @internal */ -export function isModuleWithStringLiteralName(node: Node): node is ModuleDeclaration { +export function isModuleWithStringLiteralName(node: Node): node is ModuleDeclaration & { name: StringLiteral } { return isModuleDeclaration(node) && node.name.kind === SyntaxKind.StringLiteral; } /** @internal */ -export function isNonGlobalAmbientModule(node: Node): node is ModuleDeclaration & { name: StringLiteral } { - return isModuleDeclaration(node) && isStringLiteral(node.name); -} +export const isNonGlobalAmbientModule = isModuleWithStringLiteralName; /** * An effective module (namespace) declaration is either @@ -10296,3 +10295,30 @@ export function isModuleExportNameStringLiteral(node: __String | ModuleExportNam if (!node) return false; return typeof node !== "string" && node.kind === SyntaxKind.StringLiteral; } +/** @internal */ +export function createIdentifierTextFromAnyString(name: string): string { + let targetName = ""; + // don't use c style loop, it will break Unicode surrogate pairs + for (const char of name) { + if (targetName.length === 0) { + targetName += isIdentifierStart(char.codePointAt(0)!, ScriptTarget.Latest) ? char : "_"; + } + else if (isIdentifierPart(char.codePointAt(0)!, ScriptTarget.Latest)) { + targetName += char; + } + else targetName += "_"; + } + if (!targetName.length) return "item"; + return targetName; +} +/** + * @internal + * TODO: this cannot handle the following code: + * declare class T { static prop: string; } + * export = T + * + * In this case, parent of the symbol (prop) is class T, which does not have ValueModule flag, although it is used as one. + */ +export function canSymbolBeImportedViaESImportStatement(symbol: Symbol | undefined) { + return (symbol?.parent?.flags || 0) & SymbolFlags.ValueModule; +} diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 6e7f9916748b7..1f13f60086835 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -14,6 +14,7 @@ import { compareValues, Comparison, CompilerOptions, + createIdentifierTextFromAnyString, createModuleSpecifierResolutionHost, createMultiMap, createPackageJsonImportFilter, @@ -66,6 +67,7 @@ import { isIdentifier, isIdentifierPart, isIdentifierStart, + isIdentifierText, isImportableFile, isImportEqualsDeclaration, isInJSFile, @@ -633,16 +635,21 @@ function tryUseExistingNamespaceImport(existingImports: readonly FixAddToExistin // import * as ns from "foo"; // import { member1, member2 } from "foo"; // - // member3/**/ <-- cusor here + // member3/**/ <-- cursor here // // in this case we should provie 2 actions: // 1. change "member3" to "ns.member3" // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. - return firstDefined(existingImports, ({ declaration, importKind }): FixUseNamespaceImport | undefined => { + return firstDefined(existingImports, ({ declaration, importKind, symbol }): FixUseNamespaceImport | undefined => { if (importKind !== ImportKind.Named) return undefined; const namespacePrefix = getNamespaceLikeImportText(declaration); const moduleSpecifier = namespacePrefix && tryGetModuleSpecifierFromDeclaration(declaration)?.text; + // for the code below where module "x" has an export called "hello world" + // import * as ns from "x"; + // hellow + // current completion implementation does not allow us to complet it to ns["hello world"] because we need to insert "] after the full export name inserted. + if (!isIdentifierText(symbol.name, ScriptTarget.Latest)) return undefined; if (moduleSpecifier) { return { kind: ImportFixKind.UseNamespace, namespacePrefix, usagePosition: position, moduleSpecifier }; } @@ -1413,10 +1420,14 @@ function doAddExistingFix( const comparer = OrganizeImports.getOrganizeImportsComparer(preferences, ignoreCaseForSorting); const newSpecifiers = stableSort( - namedImports.map(namedImport => factory.createImportSpecifier( - (!clause.isTypeOnly || promoteFromTypeOnly) && needsTypeOnly(namedImport), - /*propertyName*/ undefined, - factory.createIdentifier(namedImport.name))), + namedImports.map(namedImport => { + const isValidIdentifier = isIdentifierText(namedImport.name, ScriptTarget.Latest); + return factory.createImportSpecifier( + (!clause.isTypeOnly || promoteFromTypeOnly) && needsTypeOnly(namedImport), + isValidIdentifier ? undefined : factory.createStringLiteral(namedImport.name), + factory.createIdentifier(isValidIdentifier ? namedImport.name : createIdentifierTextFromAnyString(namedImport.name)) + ); + }), (s1, s2) => OrganizeImports.compareImportOrExportSpecifiers(s1, s2, comparer)); // The sorting preference computed earlier may or may not have validated that these particular @@ -1529,10 +1540,14 @@ function getNewImports( !some(namedImports, i => i.addAsTypeOnly === AddAsTypeOnly.NotAllowed); statements = combine(statements, makeImport( defaultImport && factory.createIdentifier(defaultImport.name), - namedImports?.map(({ addAsTypeOnly, name }) => factory.createImportSpecifier( - !topLevelTypeOnly && addAsTypeOnly === AddAsTypeOnly.Required, - /*propertyName*/ undefined, - factory.createIdentifier(name))), + namedImports?.map(({ addAsTypeOnly, name }) => { + const isValidIdentifier = isIdentifierText(name, ScriptTarget.Latest); + return factory.createImportSpecifier( + !topLevelTypeOnly && addAsTypeOnly === AddAsTypeOnly.Required, + isValidIdentifier ? undefined : factory.createStringLiteral(name), + factory.createIdentifier(isValidIdentifier ? name : createIdentifierTextFromAnyString(name)) + ); + }), moduleSpecifier, quotePreference, topLevelTypeOnly)); diff --git a/src/services/completions.ts b/src/services/completions.ts index 525e89a8cd21a..036346e445ff8 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -8,6 +8,7 @@ import { BreakOrContinueStatement, CancellationToken, canHaveDecorators, + canSymbolBeImportedViaESImportStatement, canUsePropertyAccess, CaseBlock, cast, @@ -36,6 +37,7 @@ import { ConstructorDeclaration, ContextFlags, countWhere, + createIdentifierTextFromAnyString, createModuleSpecifierResolutionHost, createPackageJsonImportFilter, createPrinter, @@ -207,6 +209,7 @@ import { isNamedImportsOrExports, isNamespaceImport, isNodeDescendantOf, + isNonContextualKeyword, isObjectBindingPattern, isObjectLiteralExpression, isObjectTypeDeclaration, @@ -1746,15 +1749,27 @@ function createCompletionEntry( if (originIsExport(origin) || originIsResolvedExport(origin)) { data = originToCompletionEntryData(origin); + if (!isIdentifierText(name, ScriptTarget.Latest)) { + insertText = createIdentifierTextFromAnyString(name); + filterText = name; + } hasAction = !importStatementCompletion; } const parentNamedImportOrExport = findAncestor(location, isNamedImportsOrExports); - if (parentNamedImportOrExport && !isIdentifierText(name, ScriptTarget.Latest)) { + if (parentNamedImportOrExport) { if (parentNamedImportOrExport.kind === SyntaxKind.NamedImports) { - insertText = `${quotePropertyName(sourceFile, preferences, name)} as $\{1:item}`; - isSnippet = true; + const possibleToken = stringToToken(name); + // import { break as break_ } + if (parentNamedImportOrExport && possibleToken && (possibleToken === SyntaxKind.AwaitKeyword || isNonContextualKeyword(possibleToken))) { + insertText = `${name} as ${name}_`; + } + else if (!isIdentifierText(name, ScriptTarget.Latest)) { + // import { "some thing" as some_thing } + insertText = `${quotePropertyName(sourceFile, preferences, name)} as ${createIdentifierTextFromAnyString(name)}`; + } } - else { + else if (!isIdentifierText(name, ScriptTarget.Latest)) { + // export { "some thing" } insertText = quotePropertyName(sourceFile, preferences, name); } } @@ -2461,7 +2476,7 @@ export function getCompletionEntriesFromSymbols( for (let i = 0; i < symbols.length; i++) { const symbol = symbols[i]; const origin = symbolToOriginInfoMap?.[i]; - const info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected, !!findAncestor(location, isNamedImportsOrExports)); + const info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === CompletionKind.Global && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } @@ -2671,7 +2686,7 @@ function getSymbolCompletionFromEntryId( // completion entry. return firstDefined(symbols, (symbol, index): SymbolCompletion | undefined => { const origin = symbolToOriginInfoMap[index]; - const info = getCompletionEntryDisplayNameForSymbol(symbol, getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected, !!completionData.importStatementCompletion); + const info = getCompletionEntryDisplayNameForSymbol(symbol, getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); return info && info.name === entryId.name && ( entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & SymbolFlags.ClassMember || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (SymbolFlags.Property | SymbolFlags.Method) @@ -3849,8 +3864,11 @@ function getCompletionData( exportInfo.search( sourceFile.path, /*preferCapitalized*/ isRightOfOpenTag, - (symbolName, targetFlags) => { - if (!isIdentifierText(symbolName, getEmitScriptTarget(host.getCompilationSettings()))) return false; + (symbolName, targetFlags, symbol) => { + if ( + !canSymbolBeImportedViaESImportStatement(symbol) && + !isIdentifierText(symbolName, getEmitScriptTarget(host.getCompilationSettings())) + ) return false; if (!detailsEntryId && isStringANonContextualKeyword(symbolName)) return false; if (!isTypeOnlyLocation && !importStatementCompletion && !(targetFlags & SymbolFlags.Value)) return false; if (isTypeOnlyLocation && !(targetFlags & (SymbolFlags.Module | SymbolFlags.Type))) return false; @@ -3966,7 +3984,6 @@ function getCompletionData( /*origin*/ undefined, CompletionKind.ObjectPropertyDeclaration, /*jsxIdentifierExpected*/ false, - /*moduleExportNameExpected*/ false, ); if (!displayName) { return; @@ -4807,7 +4824,6 @@ function getCompletionData( origin, CompletionKind.ObjectPropertyDeclaration, /*jsxIdentifierExpected*/ false, - /*moduleExportNameExpected*/ false ); if (displayName) { const originalSortText = symbolToSortTextMap[symbolId] ?? SortText.LocationPriority; @@ -4958,8 +4974,7 @@ function getCompletionEntryDisplayNameForSymbol( target: ScriptTarget, origin: SymbolOriginInfo | undefined, kind: CompletionKind, - jsxIdentifierExpected: boolean, - moduleExportNameExpected: boolean + jsxIdentifierExpected: boolean ): CompletionEntryDisplayNameForSymbol | undefined { if (originIsIgnore(origin)) { return undefined; @@ -4975,8 +4990,8 @@ function getCompletionEntryDisplayNameForSymbol( } const validNameResult: CompletionEntryDisplayNameForSymbol = { name, needsConvertPropertyAccess: false }; - if (moduleExportNameExpected) { - return validNameResult; + if (canSymbolBeImportedViaESImportStatement(symbol)) { + return { name, needsConvertPropertyAccess: !isIdentifierText(name, ScriptTarget.Latest) }; } if (isIdentifierText(name, target, jsxIdentifierExpected ? LanguageVariant.JSX : LanguageVariant.Standard) || symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; diff --git a/src/services/exportInfoMap.ts b/src/services/exportInfoMap.ts index 4651c1dac1c36..5ca0e9297a5d0 100644 --- a/src/services/exportInfoMap.ts +++ b/src/services/exportInfoMap.ts @@ -114,7 +114,7 @@ export interface ExportInfoMap { clear(): void; add(importingFile: Path, symbol: Symbol, key: __String, moduleSymbol: Symbol, moduleFile: SourceFile | undefined, exportKind: ExportKind, isFromPackageJson: boolean, checker: TypeChecker): void; get(importingFile: Path, key: string): readonly SymbolExportInfo[] | undefined; - search(importingFile: Path, preferCapitalized: boolean, matches: (name: string, targetFlags: SymbolFlags) => boolean, action: (info: readonly SymbolExportInfo[], symbolName: string, isFromAmbientModule: boolean, key: string) => T | undefined): T | undefined; + search(importingFile: Path, preferCapitalized: boolean, matches: (name: string, targetFlags: SymbolFlags, symbol?: Symbol) => boolean, action: (info: readonly SymbolExportInfo[], symbolName: string, isFromAmbientModule: boolean, key: string) => T | undefined): T | undefined; releaseSymbols(): void; isEmpty(): boolean; /** @returns Whether the change resulted in the cache being cleared */ @@ -230,7 +230,7 @@ export function createCacheableExportInfoMap(host: CacheableExportInfoMapHost): return forEachEntry(exportInfo, (info, key) => { const { symbolName, ambientModuleName } = parseKey(key); const name = preferCapitalized && info[0].capitalizedSymbolName || symbolName; - if (matches(name, info[0].targetFlags)) { + if (matches(name, info[0].targetFlags, info[0].symbol)) { const rehydrated = info.map(rehydrateCachedInfo); const filtered = rehydrated.filter((r, i) => isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName)); if (filtered.length) { diff --git a/tests/baselines/reference/completionInNamedImportLocation.baseline b/tests/baselines/reference/completionInNamedImportLocation.baseline new file mode 100644 index 0000000000000..83ac2f1c91450 --- /dev/null +++ b/tests/baselines/reference/completionInNamedImportLocation.baseline @@ -0,0 +1,723 @@ +=== /tests/cases/fourslash/a.ts === +// import { } from "./file"; +// ^ +// | ---------------------------------------------------------------------- +// | (alias) var await: number +// | export await +// | (alias) var "hello world": number +// | export "hello world" +// | var x: number +// | var y: number +// | type +// | ---------------------------------------------------------------------- +// import { x, } from "./file"; +// ^ +// | ---------------------------------------------------------------------- +// | (alias) var await: number +// | export await +// | (alias) var "hello world": number +// | export "hello world" +// | var y: number +// | type +// | ---------------------------------------------------------------------- +// import { x, y, } from "./file"; +// ^ +// | ---------------------------------------------------------------------- +// | (alias) var await: number +// | export await +// | (alias) var "hello world": number +// | export "hello world" +// | type +// | ---------------------------------------------------------------------- +// import { x, y, "hello world" as d, } from "./file"; +// ^ +// | ---------------------------------------------------------------------- +// | (alias) var await: number +// | export await +// | type +// | ---------------------------------------------------------------------- +// import { x, y, "hello world" as d, await as await_, } from "./file"; +// ^ +// | ---------------------------------------------------------------------- +// | No completions at /*5*/. +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 9, + "name": "1" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "await", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "await as await_", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "await", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "await", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "hello world", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "\"hello world\" as hello_world", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "x", + "kind": "var", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "y", + "kind": "var", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 39, + "name": "2" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "await", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "await as await_", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "await", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "await", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "hello world", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "\"hello world\" as hello_world", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "y", + "kind": "var", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 72, + "name": "3" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "await", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "await as await_", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "await", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "await", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "hello world", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "\"hello world\" as hello_world", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 126, + "name": "4" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "await", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "await as await_", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "await", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "await", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 196, + "name": "5" + }, + "item": {} + } +] \ No newline at end of file diff --git a/tests/baselines/reference/completionListInExportClause01.baseline b/tests/baselines/reference/completionListInExportClause01.baseline new file mode 100644 index 0000000000000..8587119f69cf5 --- /dev/null +++ b/tests/baselines/reference/completionListInExportClause01.baseline @@ -0,0 +1,1640 @@ +=== /tests/cases/fourslash/m2.ts === +// export {, from "./m1" +// ^ +// | ---------------------------------------------------------------------- +// | function bar(): number +// | function baz(): number +// | (alias) var break: number +// | export break +// | var foo: number +// | (alias) var "hello world": number +// | export "hello world" +// | type +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | function bar(): number +// | function baz(): number +// | (alias) var break: number +// | export break +// | var foo: number +// | (alias) var "hello world": number +// | export "hello world" +// | type +// | ---------------------------------------------------------------------- +// export {} from "./m1" +// ^ +// | ---------------------------------------------------------------------- +// | function bar(): number +// | function baz(): number +// | (alias) var break: number +// | export break +// | var foo: number +// | (alias) var "hello world": number +// | export "hello world" +// | type +// | ---------------------------------------------------------------------- +// export {foo, from "./m1" +// ^ +// | ---------------------------------------------------------------------- +// | function bar(): number +// | function baz(): number +// | (alias) var break: number +// | export break +// | (alias) var "hello world": number +// | export "hello world" +// | type +// | ---------------------------------------------------------------------- +// export {bar as , from "./m1" +// ^ +// | ---------------------------------------------------------------------- +// | No completions at /*5*/. +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | function baz(): number +// | (alias) var break: number +// | export break +// | var foo: number +// | (alias) var "hello world": number +// | export "hello world" +// | type +// | ---------------------------------------------------------------------- +// export {foo, bar, baz as b,} from "./m1" +// ^ +// | ---------------------------------------------------------------------- +// | (alias) var break: number +// | export break +// | (alias) var "hello world": number +// | export "hello world" +// | type +// | ---------------------------------------------------------------------- +// export {foo, bar, baz as b, "hello world" as d, } from "./m1" +// ^ +// | ---------------------------------------------------------------------- +// | (alias) var break: number +// | export break +// | type +// | ---------------------------------------------------------------------- +// export {foo, bar, baz as b, "hello world" as d, break as break_, } from "./m1" +// ^ +// | ---------------------------------------------------------------------- +// | No completions at /*9*/. +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/m2.ts", + "position": 8, + "name": "1" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "bar", + "kind": "function", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "baz", + "kind": "function", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "break", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "foo", + "kind": "var", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "hello world", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "\"hello world\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/m2.ts", + "position": 10, + "name": "2" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "bar", + "kind": "function", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "baz", + "kind": "function", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "break", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "foo", + "kind": "var", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "hello world", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/m2.ts", + "position": 31, + "name": "3" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "bar", + "kind": "function", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "baz", + "kind": "function", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "break", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "foo", + "kind": "var", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "hello world", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "\"hello world\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/m2.ts", + "position": 57, + "name": "4" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "bar", + "kind": "function", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "baz", + "kind": "function", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "break", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "hello world", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/m2.ts", + "position": 85, + "name": "5" + }, + "item": {} + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/m2.ts", + "position": 87, + "name": "6" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "baz", + "kind": "function", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "break", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "foo", + "kind": "var", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "hello world", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/m2.ts", + "position": 127, + "name": "7" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "break", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "hello world", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "insertText": "\"hello world\"", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"hello world\"", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/m2.ts", + "position": 189, + "name": "8" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": true, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "break", + "kind": "alias", + "kindModifiers": "export", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "break", + "kind": "aliasName" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/m2.ts", + "position": 268, + "name": "9" + }, + "item": {} + } +] \ No newline at end of file diff --git a/tests/baselines/reference/completionsImport_ambient.baseline b/tests/baselines/reference/completionsImport_ambient.baseline new file mode 100644 index 0000000000000..c991f965afa2f --- /dev/null +++ b/tests/baselines/reference/completionsImport_ambient.baseline @@ -0,0 +1,3537 @@ +=== /tests/cases/fourslash/b.ts === +// Ba +// ^^ +// | ---------------------------------------------------------------------- +// | abstract +// | any +// | interface Array +// | var Array: ArrayConstructor +// | interface ArrayBuffer +// | var ArrayBuffer: ArrayBufferConstructor +// | as +// | asserts +// | async +// | await +// | bigint +// | boolean +// | interface Boolean +// | var Boolean: BooleanConstructor +// | break +// | case +// | catch +// | class +// | const +// | continue +// | interface DataView +// | var DataView: DataViewConstructor +// | interface Date +// | var Date: DateConstructor +// | debugger +// | declare +// | function decodeURI(encodedURI: string): string +// | function decodeURIComponent(encodedURIComponent: string): string +// | default +// | delete +// | do +// | else +// | function encodeURI(uri: string): string +// | function encodeURIComponent(uriComponent: string | number | boolean): string +// | enum +// | interface Error +// | var Error: ErrorConstructor +// | function eval(x: string): any +// | interface EvalError +// | var EvalError: EvalErrorConstructor +// | export +// | extends +// | false +// | finally +// | interface Float32Array +// | var Float32Array: Float32ArrayConstructor +// | interface Float64Array +// | var Float64Array: Float64ArrayConstructor +// | namespace foo +// | for +// | function +// | interface Function +// | var Function: FunctionConstructor +// | module globalThis +// | if +// | implements +// | import +// | in +// | infer +// | var Infinity: number +// | instanceof +// | interface Int16Array +// | var Int16Array: Int16ArrayConstructor +// | interface Int32Array +// | var Int32Array: Int32ArrayConstructor +// | interface Int8Array +// | var Int8Array: Int8ArrayConstructor +// | interface +// | namespace Intl +// | function isFinite(number: number): boolean +// | function isNaN(number: number): boolean +// | interface JSON +// | var JSON: JSON +// | keyof +// | let +// | interface Math +// | var Math: Math +// | module +// | namespace +// | var NaN: number +// | never +// | new +// | null +// | number +// | interface Number +// | var Number: NumberConstructor +// | object +// | interface Object +// | var Object: ObjectConstructor +// | package +// | function parseFloat(string: string): number +// | function parseInt(string: string, radix?: number): number +// | interface RangeError +// | var RangeError: RangeErrorConstructor +// | readonly +// | interface ReferenceError +// | var ReferenceError: ReferenceErrorConstructor +// | interface RegExp +// | var RegExp: RegExpConstructor +// | return +// | satisfies +// | string +// | interface String +// | var String: StringConstructor +// | super +// | switch +// | symbol +// | interface SyntaxError +// | var SyntaxError: SyntaxErrorConstructor +// | this +// | throw +// | true +// | try +// | type +// | interface TypeError +// | var TypeError: TypeErrorConstructor +// | typeof +// | interface Uint16Array +// | var Uint16Array: Uint16ArrayConstructor +// | interface Uint32Array +// | var Uint32Array: Uint32ArrayConstructor +// | interface Uint8Array +// | var Uint8Array: Uint8ArrayConstructor +// | interface Uint8ClampedArray +// | var Uint8ClampedArray: Uint8ClampedArrayConstructor +// | var undefined +// | unique +// | unknown +// | interface URIError +// | var URIError: URIErrorConstructor +// | var +// | void +// | while +// | with +// | yield +// | function escape(string: string): string +// | function unescape(string: string): string +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/b.ts", + "position": 2, + "name": "1" + }, + "item": { + "flags": 0, + "isGlobalCompletion": true, + "isMemberCompletion": false, + "isNewIdentifierLocation": false, + "optionalReplacementSpan": { + "start": 0, + "length": 2 + }, + "entries": [ + { + "name": "abstract", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "abstract", + "kind": "keyword" + } + ] + }, + { + "name": "any", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "any", + "kind": "keyword" + } + ] + }, + { + "name": "Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Array", + "kind": "localName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "ArrayBuffer", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayBuffer", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayBuffer", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayBufferConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Represents a raw buffer of binary data, which is used to store data for the\ndifferent typed arrays. ArrayBuffers cannot be read from or written to directly,\nbut can be passed to a typed array or DataView Object to interpret the raw\nbuffer as needed.", + "kind": "text" + } + ] + }, + { + "name": "as", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "as", + "kind": "keyword" + } + ] + }, + { + "name": "asserts", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "asserts", + "kind": "keyword" + } + ] + }, + { + "name": "async", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "async", + "kind": "keyword" + } + ] + }, + { + "name": "await", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "await", + "kind": "keyword" + } + ] + }, + { + "name": "bigint", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "bigint", + "kind": "keyword" + } + ] + }, + { + "name": "boolean", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "boolean", + "kind": "keyword" + } + ] + }, + { + "name": "Boolean", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Boolean", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Boolean", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BooleanConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "break", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "break", + "kind": "keyword" + } + ] + }, + { + "name": "case", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "case", + "kind": "keyword" + } + ] + }, + { + "name": "catch", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "catch", + "kind": "keyword" + } + ] + }, + { + "name": "class", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "class", + "kind": "keyword" + } + ] + }, + { + "name": "const", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "const", + "kind": "keyword" + } + ] + }, + { + "name": "continue", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "continue", + "kind": "keyword" + } + ] + }, + { + "name": "DataView", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DataView", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DataView", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DataViewConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "Date", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DateConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Enables basic storage and retrieval of dates and times.", + "kind": "text" + } + ] + }, + { + "name": "debugger", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "debugger", + "kind": "keyword" + } + ] + }, + { + "name": "declare", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "declare", + "kind": "keyword" + } + ] + }, + { + "name": "decodeURI", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "decodeURI", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "encodedURI", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Gets the unencoded version of an encoded Uniform Resource Identifier (URI).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "encodedURI", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an encoded URI.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "decodeURIComponent", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "decodeURIComponent", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "encodedURIComponent", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "encodedURIComponent", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an encoded URI component.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "default", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "default", + "kind": "keyword" + } + ] + }, + { + "name": "delete", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "delete", + "kind": "keyword" + } + ] + }, + { + "name": "do", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "do", + "kind": "keyword" + } + ] + }, + { + "name": "else", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "else", + "kind": "keyword" + } + ] + }, + { + "name": "encodeURI", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "encodeURI", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "uri", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Encodes a text string as a valid Uniform Resource Identifier (URI)", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "uri", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an unencoded URI.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "encodeURIComponent", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "encodeURIComponent", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "uriComponent", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Encodes a text string as a valid component of a Uniform Resource Identifier (URI).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "uriComponent", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an unencoded URI component.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "enum", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "enum", + "kind": "keyword" + } + ] + }, + { + "name": "Error", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Error", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Error", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "eval", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "eval", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Evaluates JavaScript code and executes it.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "x", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A String value that contains valid JavaScript code.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "EvalError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "EvalError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "EvalError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "EvalErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "export", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "export", + "kind": "keyword" + } + ] + }, + { + "name": "extends", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "extends", + "kind": "keyword" + } + ] + }, + { + "name": "false", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "false", + "kind": "keyword" + } + ] + }, + { + "name": "finally", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "finally", + "kind": "keyword" + } + ] + }, + { + "name": "Float32Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float32Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float32Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float32ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 32-bit float values. The contents are initialized to 0. If the requested number\nof bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Float64Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float64Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float64Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float64ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 64-bit float values. The contents are initialized to 0. If the requested\nnumber of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "foo", + "kind": "module", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "moduleName" + } + ], + "documentation": [] + }, + { + "name": "for", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "for", + "kind": "keyword" + } + ] + }, + { + "name": "function", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + } + ] + }, + { + "name": "Function", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Function", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Function", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FunctionConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Creates a new function.", + "kind": "text" + } + ] + }, + { + "name": "globalThis", + "kind": "module", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "module", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "globalThis", + "kind": "moduleName" + } + ], + "documentation": [] + }, + { + "name": "if", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "if", + "kind": "keyword" + } + ] + }, + { + "name": "implements", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "implements", + "kind": "keyword" + } + ] + }, + { + "name": "import", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "import", + "kind": "keyword" + } + ] + }, + { + "name": "in", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "in", + "kind": "keyword" + } + ] + }, + { + "name": "infer", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "infer", + "kind": "keyword" + } + ] + }, + { + "name": "Infinity", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Infinity", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "instanceof", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "instanceof", + "kind": "keyword" + } + ] + }, + { + "name": "Int16Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int16Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int16Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int16ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 16-bit signed integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Int32Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int32Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int32Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int32ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 32-bit signed integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Int8Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int8Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int8Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int8ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 8-bit integer values. The contents are initialized to 0. If the requested\nnumber of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "interface", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + } + ] + }, + { + "name": "Intl", + "kind": "module", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Intl", + "kind": "moduleName" + } + ], + "documentation": [] + }, + { + "name": "isFinite", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "isFinite", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Determines whether a supplied number is finite.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "number", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Any numeric value.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "isNaN", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "isNaN", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "number", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A numeric value.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "JSON", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "JSON", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "JSON", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "JSON", + "kind": "localName" + } + ], + "documentation": [ + { + "text": "An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.", + "kind": "text" + } + ] + }, + { + "name": "keyof", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "keyof", + "kind": "keyword" + } + ] + }, + { + "name": "let", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "let", + "kind": "keyword" + } + ] + }, + { + "name": "Math", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Math", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Math", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Math", + "kind": "localName" + } + ], + "documentation": [ + { + "text": "An intrinsic object that provides basic mathematics functionality and constants.", + "kind": "text" + } + ] + }, + { + "name": "module", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "module", + "kind": "keyword" + } + ] + }, + { + "name": "namespace", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + } + ] + }, + { + "name": "NaN", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "NaN", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "never", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "never", + "kind": "keyword" + } + ] + }, + { + "name": "new", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "new", + "kind": "keyword" + } + ] + }, + { + "name": "null", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "null", + "kind": "keyword" + } + ] + }, + { + "name": "number", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "number", + "kind": "keyword" + } + ] + }, + { + "name": "Number", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Number", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Number", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "NumberConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.", + "kind": "text" + } + ] + }, + { + "name": "object", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "object", + "kind": "keyword" + } + ] + }, + { + "name": "Object", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Object", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Object", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ObjectConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Provides functionality common to all JavaScript objects.", + "kind": "text" + } + ] + }, + { + "name": "package", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "package", + "kind": "keyword" + } + ] + }, + { + "name": "parseFloat", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "parseFloat", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Converts a string to a floating-point number.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string that contains a floating-point number.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "parseInt", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "parseInt", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "radix", + "kind": "parameterName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Converts a string to an integer.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string to convert into a number.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "radix", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value between 2 and 36 that specifies the base of the number in `string`.\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\nAll other strings are considered decimal.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "RangeError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RangeError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RangeError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RangeErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "readonly", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "readonly", + "kind": "keyword" + } + ] + }, + { + "name": "ReferenceError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ReferenceError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ReferenceError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ReferenceErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "RegExp", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RegExp", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RegExp", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RegExpConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "return", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "return", + "kind": "keyword" + } + ] + }, + { + "name": "satisfies", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "satisfies", + "kind": "keyword" + } + ] + }, + { + "name": "string", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "string", + "kind": "keyword" + } + ] + }, + { + "name": "String", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "String", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "String", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "StringConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Allows manipulation and formatting of text strings and determination and location of substrings within strings.", + "kind": "text" + } + ] + }, + { + "name": "super", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "super", + "kind": "keyword" + } + ] + }, + { + "name": "switch", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "switch", + "kind": "keyword" + } + ] + }, + { + "name": "symbol", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "symbol", + "kind": "keyword" + } + ] + }, + { + "name": "SyntaxError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SyntaxError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SyntaxError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SyntaxErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "this", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "this", + "kind": "keyword" + } + ] + }, + { + "name": "throw", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "throw", + "kind": "keyword" + } + ] + }, + { + "name": "true", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "true", + "kind": "keyword" + } + ] + }, + { + "name": "try", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "try", + "kind": "keyword" + } + ] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + }, + { + "name": "TypeError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TypeError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TypeError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TypeErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "typeof", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "typeof", + "kind": "keyword" + } + ] + }, + { + "name": "Uint16Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint16Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint16Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint16ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Uint32Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint32Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint32Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint32ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Uint8Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Uint8ClampedArray", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ClampedArray", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ClampedArray", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ClampedArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.\nIf the requested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "undefined", + "kind": "var", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "undefined", + "kind": "propertyName" + } + ], + "documentation": [] + }, + { + "name": "unique", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "unique", + "kind": "keyword" + } + ] + }, + { + "name": "unknown", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "unknown", + "kind": "keyword" + } + ] + }, + { + "name": "URIError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "URIError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "URIError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "URIErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "var", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + } + ] + }, + { + "name": "void", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "void", + "kind": "keyword" + } + ] + }, + { + "name": "while", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "while", + "kind": "keyword" + } + ] + }, + { + "name": "with", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "with", + "kind": "keyword" + } + ] + }, + { + "name": "yield", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "yield", + "kind": "keyword" + } + ] + }, + { + "name": "escape", + "kind": "function", + "kindModifiers": "deprecated,declare", + "sortText": "z15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "escape", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence.", + "kind": "text" + } + ], + "tags": [ + { + "name": "deprecated", + "text": [ + { + "text": "A legacy feature for browser compatibility", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string value", + "kind": "text" + } + ] + } + ] + }, + { + "name": "unescape", + "kind": "function", + "kindModifiers": "deprecated,declare", + "sortText": "z15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "unescape", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents.", + "kind": "text" + } + ], + "tags": [ + { + "name": "deprecated", + "text": [ + { + "text": "A legacy feature for browser compatibility", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string value", + "kind": "text" + } + ] + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/completionsImport_augmentation.baseline b/tests/baselines/reference/completionsImport_augmentation.baseline new file mode 100644 index 0000000000000..1d8f09651acb8 --- /dev/null +++ b/tests/baselines/reference/completionsImport_augmentation.baseline @@ -0,0 +1,3511 @@ +=== /user.ts === +// +// ^ +// | ---------------------------------------------------------------------- +// | abstract +// | any +// | interface Array +// | var Array: ArrayConstructor +// | interface ArrayBuffer +// | var ArrayBuffer: ArrayBufferConstructor +// | as +// | asserts +// | async +// | await +// | bigint +// | boolean +// | interface Boolean +// | var Boolean: BooleanConstructor +// | break +// | case +// | catch +// | class +// | const +// | continue +// | interface DataView +// | var DataView: DataViewConstructor +// | interface Date +// | var Date: DateConstructor +// | debugger +// | declare +// | function decodeURI(encodedURI: string): string +// | function decodeURIComponent(encodedURIComponent: string): string +// | default +// | delete +// | do +// | else +// | function encodeURI(uri: string): string +// | function encodeURIComponent(uriComponent: string | number | boolean): string +// | enum +// | interface Error +// | var Error: ErrorConstructor +// | function eval(x: string): any +// | interface EvalError +// | var EvalError: EvalErrorConstructor +// | export +// | extends +// | false +// | finally +// | interface Float32Array +// | var Float32Array: Float32ArrayConstructor +// | interface Float64Array +// | var Float64Array: Float64ArrayConstructor +// | for +// | function +// | interface Function +// | var Function: FunctionConstructor +// | module globalThis +// | if +// | implements +// | import +// | in +// | infer +// | var Infinity: number +// | instanceof +// | interface Int16Array +// | var Int16Array: Int16ArrayConstructor +// | interface Int32Array +// | var Int32Array: Int32ArrayConstructor +// | interface Int8Array +// | var Int8Array: Int8ArrayConstructor +// | interface +// | namespace Intl +// | function isFinite(number: number): boolean +// | function isNaN(number: number): boolean +// | interface JSON +// | var JSON: JSON +// | keyof +// | let +// | interface Math +// | var Math: Math +// | module +// | namespace +// | var NaN: number +// | never +// | new +// | null +// | number +// | interface Number +// | var Number: NumberConstructor +// | object +// | interface Object +// | var Object: ObjectConstructor +// | package +// | function parseFloat(string: string): number +// | function parseInt(string: string, radix?: number): number +// | interface RangeError +// | var RangeError: RangeErrorConstructor +// | readonly +// | interface ReferenceError +// | var ReferenceError: ReferenceErrorConstructor +// | interface RegExp +// | var RegExp: RegExpConstructor +// | return +// | satisfies +// | string +// | interface String +// | var String: StringConstructor +// | super +// | switch +// | symbol +// | interface SyntaxError +// | var SyntaxError: SyntaxErrorConstructor +// | this +// | throw +// | true +// | try +// | type +// | interface TypeError +// | var TypeError: TypeErrorConstructor +// | typeof +// | interface Uint16Array +// | var Uint16Array: Uint16ArrayConstructor +// | interface Uint32Array +// | var Uint32Array: Uint32ArrayConstructor +// | interface Uint8Array +// | var Uint8Array: Uint8ArrayConstructor +// | interface Uint8ClampedArray +// | var Uint8ClampedArray: Uint8ClampedArrayConstructor +// | var undefined +// | unique +// | unknown +// | interface URIError +// | var URIError: URIErrorConstructor +// | var +// | void +// | while +// | with +// | yield +// | function escape(string: string): string +// | function unescape(string: string): string +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/user.ts", + "position": 0, + "name": "" + }, + "item": { + "flags": 0, + "isGlobalCompletion": true, + "isMemberCompletion": false, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "abstract", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "abstract", + "kind": "keyword" + } + ] + }, + { + "name": "any", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "any", + "kind": "keyword" + } + ] + }, + { + "name": "Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Array", + "kind": "localName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "ArrayBuffer", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayBuffer", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayBuffer", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayBufferConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Represents a raw buffer of binary data, which is used to store data for the\ndifferent typed arrays. ArrayBuffers cannot be read from or written to directly,\nbut can be passed to a typed array or DataView Object to interpret the raw\nbuffer as needed.", + "kind": "text" + } + ] + }, + { + "name": "as", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "as", + "kind": "keyword" + } + ] + }, + { + "name": "asserts", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "asserts", + "kind": "keyword" + } + ] + }, + { + "name": "async", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "async", + "kind": "keyword" + } + ] + }, + { + "name": "await", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "await", + "kind": "keyword" + } + ] + }, + { + "name": "bigint", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "bigint", + "kind": "keyword" + } + ] + }, + { + "name": "boolean", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "boolean", + "kind": "keyword" + } + ] + }, + { + "name": "Boolean", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Boolean", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Boolean", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BooleanConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "break", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "break", + "kind": "keyword" + } + ] + }, + { + "name": "case", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "case", + "kind": "keyword" + } + ] + }, + { + "name": "catch", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "catch", + "kind": "keyword" + } + ] + }, + { + "name": "class", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "class", + "kind": "keyword" + } + ] + }, + { + "name": "const", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "const", + "kind": "keyword" + } + ] + }, + { + "name": "continue", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "continue", + "kind": "keyword" + } + ] + }, + { + "name": "DataView", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DataView", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DataView", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DataViewConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "Date", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DateConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Enables basic storage and retrieval of dates and times.", + "kind": "text" + } + ] + }, + { + "name": "debugger", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "debugger", + "kind": "keyword" + } + ] + }, + { + "name": "declare", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "declare", + "kind": "keyword" + } + ] + }, + { + "name": "decodeURI", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "decodeURI", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "encodedURI", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Gets the unencoded version of an encoded Uniform Resource Identifier (URI).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "encodedURI", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an encoded URI.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "decodeURIComponent", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "decodeURIComponent", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "encodedURIComponent", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "encodedURIComponent", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an encoded URI component.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "default", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "default", + "kind": "keyword" + } + ] + }, + { + "name": "delete", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "delete", + "kind": "keyword" + } + ] + }, + { + "name": "do", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "do", + "kind": "keyword" + } + ] + }, + { + "name": "else", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "else", + "kind": "keyword" + } + ] + }, + { + "name": "encodeURI", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "encodeURI", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "uri", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Encodes a text string as a valid Uniform Resource Identifier (URI)", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "uri", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an unencoded URI.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "encodeURIComponent", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "encodeURIComponent", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "uriComponent", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Encodes a text string as a valid component of a Uniform Resource Identifier (URI).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "uriComponent", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an unencoded URI component.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "enum", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "enum", + "kind": "keyword" + } + ] + }, + { + "name": "Error", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Error", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Error", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "eval", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "eval", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Evaluates JavaScript code and executes it.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "x", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A String value that contains valid JavaScript code.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "EvalError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "EvalError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "EvalError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "EvalErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "export", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "export", + "kind": "keyword" + } + ] + }, + { + "name": "extends", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "extends", + "kind": "keyword" + } + ] + }, + { + "name": "false", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "false", + "kind": "keyword" + } + ] + }, + { + "name": "finally", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "finally", + "kind": "keyword" + } + ] + }, + { + "name": "Float32Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float32Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float32Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float32ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 32-bit float values. The contents are initialized to 0. If the requested number\nof bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Float64Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float64Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float64Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float64ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 64-bit float values. The contents are initialized to 0. If the requested\nnumber of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "for", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "for", + "kind": "keyword" + } + ] + }, + { + "name": "function", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + } + ] + }, + { + "name": "Function", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Function", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Function", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FunctionConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Creates a new function.", + "kind": "text" + } + ] + }, + { + "name": "globalThis", + "kind": "module", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "module", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "globalThis", + "kind": "moduleName" + } + ], + "documentation": [] + }, + { + "name": "if", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "if", + "kind": "keyword" + } + ] + }, + { + "name": "implements", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "implements", + "kind": "keyword" + } + ] + }, + { + "name": "import", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "import", + "kind": "keyword" + } + ] + }, + { + "name": "in", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "in", + "kind": "keyword" + } + ] + }, + { + "name": "infer", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "infer", + "kind": "keyword" + } + ] + }, + { + "name": "Infinity", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Infinity", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "instanceof", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "instanceof", + "kind": "keyword" + } + ] + }, + { + "name": "Int16Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int16Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int16Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int16ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 16-bit signed integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Int32Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int32Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int32Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int32ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 32-bit signed integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Int8Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int8Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int8Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int8ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 8-bit integer values. The contents are initialized to 0. If the requested\nnumber of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "interface", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + } + ] + }, + { + "name": "Intl", + "kind": "module", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Intl", + "kind": "moduleName" + } + ], + "documentation": [] + }, + { + "name": "isFinite", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "isFinite", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Determines whether a supplied number is finite.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "number", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Any numeric value.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "isNaN", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "isNaN", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "number", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A numeric value.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "JSON", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "JSON", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "JSON", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "JSON", + "kind": "localName" + } + ], + "documentation": [ + { + "text": "An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.", + "kind": "text" + } + ] + }, + { + "name": "keyof", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "keyof", + "kind": "keyword" + } + ] + }, + { + "name": "let", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "let", + "kind": "keyword" + } + ] + }, + { + "name": "Math", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Math", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Math", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Math", + "kind": "localName" + } + ], + "documentation": [ + { + "text": "An intrinsic object that provides basic mathematics functionality and constants.", + "kind": "text" + } + ] + }, + { + "name": "module", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "module", + "kind": "keyword" + } + ] + }, + { + "name": "namespace", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + } + ] + }, + { + "name": "NaN", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "NaN", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "never", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "never", + "kind": "keyword" + } + ] + }, + { + "name": "new", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "new", + "kind": "keyword" + } + ] + }, + { + "name": "null", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "null", + "kind": "keyword" + } + ] + }, + { + "name": "number", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "number", + "kind": "keyword" + } + ] + }, + { + "name": "Number", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Number", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Number", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "NumberConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.", + "kind": "text" + } + ] + }, + { + "name": "object", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "object", + "kind": "keyword" + } + ] + }, + { + "name": "Object", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Object", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Object", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ObjectConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Provides functionality common to all JavaScript objects.", + "kind": "text" + } + ] + }, + { + "name": "package", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "package", + "kind": "keyword" + } + ] + }, + { + "name": "parseFloat", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "parseFloat", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Converts a string to a floating-point number.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string that contains a floating-point number.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "parseInt", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "parseInt", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "radix", + "kind": "parameterName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Converts a string to an integer.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string to convert into a number.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "radix", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value between 2 and 36 that specifies the base of the number in `string`.\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\nAll other strings are considered decimal.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "RangeError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RangeError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RangeError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RangeErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "readonly", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "readonly", + "kind": "keyword" + } + ] + }, + { + "name": "ReferenceError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ReferenceError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ReferenceError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ReferenceErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "RegExp", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RegExp", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RegExp", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RegExpConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "return", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "return", + "kind": "keyword" + } + ] + }, + { + "name": "satisfies", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "satisfies", + "kind": "keyword" + } + ] + }, + { + "name": "string", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "string", + "kind": "keyword" + } + ] + }, + { + "name": "String", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "String", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "String", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "StringConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Allows manipulation and formatting of text strings and determination and location of substrings within strings.", + "kind": "text" + } + ] + }, + { + "name": "super", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "super", + "kind": "keyword" + } + ] + }, + { + "name": "switch", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "switch", + "kind": "keyword" + } + ] + }, + { + "name": "symbol", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "symbol", + "kind": "keyword" + } + ] + }, + { + "name": "SyntaxError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SyntaxError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SyntaxError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SyntaxErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "this", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "this", + "kind": "keyword" + } + ] + }, + { + "name": "throw", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "throw", + "kind": "keyword" + } + ] + }, + { + "name": "true", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "true", + "kind": "keyword" + } + ] + }, + { + "name": "try", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "try", + "kind": "keyword" + } + ] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + }, + { + "name": "TypeError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TypeError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TypeError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TypeErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "typeof", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "typeof", + "kind": "keyword" + } + ] + }, + { + "name": "Uint16Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint16Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint16Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint16ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Uint32Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint32Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint32Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint32ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Uint8Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Uint8ClampedArray", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ClampedArray", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ClampedArray", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ClampedArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.\nIf the requested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "undefined", + "kind": "var", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "undefined", + "kind": "propertyName" + } + ], + "documentation": [] + }, + { + "name": "unique", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "unique", + "kind": "keyword" + } + ] + }, + { + "name": "unknown", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "unknown", + "kind": "keyword" + } + ] + }, + { + "name": "URIError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "URIError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "URIError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "URIErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "var", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + } + ] + }, + { + "name": "void", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "void", + "kind": "keyword" + } + ] + }, + { + "name": "while", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "while", + "kind": "keyword" + } + ] + }, + { + "name": "with", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "with", + "kind": "keyword" + } + ] + }, + { + "name": "yield", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "yield", + "kind": "keyword" + } + ] + }, + { + "name": "escape", + "kind": "function", + "kindModifiers": "deprecated,declare", + "sortText": "z15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "escape", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence.", + "kind": "text" + } + ], + "tags": [ + { + "name": "deprecated", + "text": [ + { + "text": "A legacy feature for browser compatibility", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string value", + "kind": "text" + } + ] + } + ] + }, + { + "name": "unescape", + "kind": "function", + "kindModifiers": "deprecated,declare", + "sortText": "z15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "unescape", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents.", + "kind": "text" + } + ], + "tags": [ + { + "name": "deprecated", + "text": [ + { + "text": "A legacy feature for browser compatibility", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string value", + "kind": "text" + } + ] + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/completionsImport_fromAmbientModule.baseline b/tests/baselines/reference/completionsImport_fromAmbientModule.baseline new file mode 100644 index 0000000000000..738c45f4b42c7 --- /dev/null +++ b/tests/baselines/reference/completionsImport_fromAmbientModule.baseline @@ -0,0 +1,3511 @@ +=== /b.ts === +// +// ^ +// | ---------------------------------------------------------------------- +// | abstract +// | any +// | interface Array +// | var Array: ArrayConstructor +// | interface ArrayBuffer +// | var ArrayBuffer: ArrayBufferConstructor +// | as +// | asserts +// | async +// | await +// | bigint +// | boolean +// | interface Boolean +// | var Boolean: BooleanConstructor +// | break +// | case +// | catch +// | class +// | const +// | continue +// | interface DataView +// | var DataView: DataViewConstructor +// | interface Date +// | var Date: DateConstructor +// | debugger +// | declare +// | function decodeURI(encodedURI: string): string +// | function decodeURIComponent(encodedURIComponent: string): string +// | default +// | delete +// | do +// | else +// | function encodeURI(uri: string): string +// | function encodeURIComponent(uriComponent: string | number | boolean): string +// | enum +// | interface Error +// | var Error: ErrorConstructor +// | function eval(x: string): any +// | interface EvalError +// | var EvalError: EvalErrorConstructor +// | export +// | extends +// | false +// | finally +// | interface Float32Array +// | var Float32Array: Float32ArrayConstructor +// | interface Float64Array +// | var Float64Array: Float64ArrayConstructor +// | for +// | function +// | interface Function +// | var Function: FunctionConstructor +// | module globalThis +// | if +// | implements +// | import +// | in +// | infer +// | var Infinity: number +// | instanceof +// | interface Int16Array +// | var Int16Array: Int16ArrayConstructor +// | interface Int32Array +// | var Int32Array: Int32ArrayConstructor +// | interface Int8Array +// | var Int8Array: Int8ArrayConstructor +// | interface +// | namespace Intl +// | function isFinite(number: number): boolean +// | function isNaN(number: number): boolean +// | interface JSON +// | var JSON: JSON +// | keyof +// | let +// | interface Math +// | var Math: Math +// | module +// | namespace +// | var NaN: number +// | never +// | new +// | null +// | number +// | interface Number +// | var Number: NumberConstructor +// | object +// | interface Object +// | var Object: ObjectConstructor +// | package +// | function parseFloat(string: string): number +// | function parseInt(string: string, radix?: number): number +// | interface RangeError +// | var RangeError: RangeErrorConstructor +// | readonly +// | interface ReferenceError +// | var ReferenceError: ReferenceErrorConstructor +// | interface RegExp +// | var RegExp: RegExpConstructor +// | return +// | satisfies +// | string +// | interface String +// | var String: StringConstructor +// | super +// | switch +// | symbol +// | interface SyntaxError +// | var SyntaxError: SyntaxErrorConstructor +// | this +// | throw +// | true +// | try +// | type +// | interface TypeError +// | var TypeError: TypeErrorConstructor +// | typeof +// | interface Uint16Array +// | var Uint16Array: Uint16ArrayConstructor +// | interface Uint32Array +// | var Uint32Array: Uint32ArrayConstructor +// | interface Uint8Array +// | var Uint8Array: Uint8ArrayConstructor +// | interface Uint8ClampedArray +// | var Uint8ClampedArray: Uint8ClampedArrayConstructor +// | var undefined +// | unique +// | unknown +// | interface URIError +// | var URIError: URIErrorConstructor +// | var +// | void +// | while +// | with +// | yield +// | function escape(string: string): string +// | function unescape(string: string): string +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/b.ts", + "position": 0, + "name": "" + }, + "item": { + "flags": 0, + "isGlobalCompletion": true, + "isMemberCompletion": false, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "abstract", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "abstract", + "kind": "keyword" + } + ] + }, + { + "name": "any", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "any", + "kind": "keyword" + } + ] + }, + { + "name": "Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Array", + "kind": "localName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "ArrayBuffer", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayBuffer", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayBuffer", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ArrayBufferConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Represents a raw buffer of binary data, which is used to store data for the\ndifferent typed arrays. ArrayBuffers cannot be read from or written to directly,\nbut can be passed to a typed array or DataView Object to interpret the raw\nbuffer as needed.", + "kind": "text" + } + ] + }, + { + "name": "as", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "as", + "kind": "keyword" + } + ] + }, + { + "name": "asserts", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "asserts", + "kind": "keyword" + } + ] + }, + { + "name": "async", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "async", + "kind": "keyword" + } + ] + }, + { + "name": "await", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "await", + "kind": "keyword" + } + ] + }, + { + "name": "bigint", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "bigint", + "kind": "keyword" + } + ] + }, + { + "name": "boolean", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "boolean", + "kind": "keyword" + } + ] + }, + { + "name": "Boolean", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Boolean", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Boolean", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BooleanConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "break", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "break", + "kind": "keyword" + } + ] + }, + { + "name": "case", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "case", + "kind": "keyword" + } + ] + }, + { + "name": "catch", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "catch", + "kind": "keyword" + } + ] + }, + { + "name": "class", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "class", + "kind": "keyword" + } + ] + }, + { + "name": "const", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "const", + "kind": "keyword" + } + ] + }, + { + "name": "continue", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "continue", + "kind": "keyword" + } + ] + }, + { + "name": "DataView", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DataView", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DataView", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DataViewConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "Date", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "DateConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Enables basic storage and retrieval of dates and times.", + "kind": "text" + } + ] + }, + { + "name": "debugger", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "debugger", + "kind": "keyword" + } + ] + }, + { + "name": "declare", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "declare", + "kind": "keyword" + } + ] + }, + { + "name": "decodeURI", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "decodeURI", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "encodedURI", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Gets the unencoded version of an encoded Uniform Resource Identifier (URI).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "encodedURI", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an encoded URI.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "decodeURIComponent", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "decodeURIComponent", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "encodedURIComponent", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "encodedURIComponent", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an encoded URI component.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "default", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "default", + "kind": "keyword" + } + ] + }, + { + "name": "delete", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "delete", + "kind": "keyword" + } + ] + }, + { + "name": "do", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "do", + "kind": "keyword" + } + ] + }, + { + "name": "else", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "else", + "kind": "keyword" + } + ] + }, + { + "name": "encodeURI", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "encodeURI", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "uri", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Encodes a text string as a valid Uniform Resource Identifier (URI)", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "uri", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an unencoded URI.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "encodeURIComponent", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "encodeURIComponent", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "uriComponent", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Encodes a text string as a valid component of a Uniform Resource Identifier (URI).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "uriComponent", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value representing an unencoded URI component.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "enum", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "enum", + "kind": "keyword" + } + ] + }, + { + "name": "Error", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Error", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Error", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "eval", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "eval", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Evaluates JavaScript code and executes it.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "x", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A String value that contains valid JavaScript code.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "EvalError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "EvalError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "EvalError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "EvalErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "export", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "export", + "kind": "keyword" + } + ] + }, + { + "name": "extends", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "extends", + "kind": "keyword" + } + ] + }, + { + "name": "false", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "false", + "kind": "keyword" + } + ] + }, + { + "name": "finally", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "finally", + "kind": "keyword" + } + ] + }, + { + "name": "Float32Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float32Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float32Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float32ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 32-bit float values. The contents are initialized to 0. If the requested number\nof bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Float64Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float64Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float64Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Float64ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 64-bit float values. The contents are initialized to 0. If the requested\nnumber of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "for", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "for", + "kind": "keyword" + } + ] + }, + { + "name": "function", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + } + ] + }, + { + "name": "Function", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Function", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Function", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FunctionConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Creates a new function.", + "kind": "text" + } + ] + }, + { + "name": "globalThis", + "kind": "module", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "module", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "globalThis", + "kind": "moduleName" + } + ], + "documentation": [] + }, + { + "name": "if", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "if", + "kind": "keyword" + } + ] + }, + { + "name": "implements", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "implements", + "kind": "keyword" + } + ] + }, + { + "name": "import", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "import", + "kind": "keyword" + } + ] + }, + { + "name": "in", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "in", + "kind": "keyword" + } + ] + }, + { + "name": "infer", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "infer", + "kind": "keyword" + } + ] + }, + { + "name": "Infinity", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Infinity", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "instanceof", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "instanceof", + "kind": "keyword" + } + ] + }, + { + "name": "Int16Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int16Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int16Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int16ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 16-bit signed integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Int32Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int32Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int32Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int32ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 32-bit signed integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Int8Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int8Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int8Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Int8ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 8-bit integer values. The contents are initialized to 0. If the requested\nnumber of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "interface", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + } + ] + }, + { + "name": "Intl", + "kind": "module", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Intl", + "kind": "moduleName" + } + ], + "documentation": [] + }, + { + "name": "isFinite", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "isFinite", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Determines whether a supplied number is finite.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "number", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Any numeric value.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "isNaN", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "isNaN", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number).", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "number", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A numeric value.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "JSON", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "JSON", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "JSON", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "JSON", + "kind": "localName" + } + ], + "documentation": [ + { + "text": "An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.", + "kind": "text" + } + ] + }, + { + "name": "keyof", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "keyof", + "kind": "keyword" + } + ] + }, + { + "name": "let", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "let", + "kind": "keyword" + } + ] + }, + { + "name": "Math", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Math", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Math", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Math", + "kind": "localName" + } + ], + "documentation": [ + { + "text": "An intrinsic object that provides basic mathematics functionality and constants.", + "kind": "text" + } + ] + }, + { + "name": "module", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "module", + "kind": "keyword" + } + ] + }, + { + "name": "namespace", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + } + ] + }, + { + "name": "NaN", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "NaN", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [] + }, + { + "name": "never", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "never", + "kind": "keyword" + } + ] + }, + { + "name": "new", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "new", + "kind": "keyword" + } + ] + }, + { + "name": "null", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "null", + "kind": "keyword" + } + ] + }, + { + "name": "number", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "number", + "kind": "keyword" + } + ] + }, + { + "name": "Number", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Number", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Number", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "NumberConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.", + "kind": "text" + } + ] + }, + { + "name": "object", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "object", + "kind": "keyword" + } + ] + }, + { + "name": "Object", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Object", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Object", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ObjectConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Provides functionality common to all JavaScript objects.", + "kind": "text" + } + ] + }, + { + "name": "package", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "package", + "kind": "keyword" + } + ] + }, + { + "name": "parseFloat", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "parseFloat", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Converts a string to a floating-point number.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string that contains a floating-point number.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "parseInt", + "kind": "function", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "parseInt", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "radix", + "kind": "parameterName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Converts a string to an integer.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string to convert into a number.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "radix", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A value between 2 and 36 that specifies the base of the number in `string`.\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\nAll other strings are considered decimal.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "RangeError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RangeError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RangeError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RangeErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "readonly", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "readonly", + "kind": "keyword" + } + ] + }, + { + "name": "ReferenceError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ReferenceError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ReferenceError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ReferenceErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "RegExp", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RegExp", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RegExp", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "RegExpConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "return", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "return", + "kind": "keyword" + } + ] + }, + { + "name": "satisfies", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "satisfies", + "kind": "keyword" + } + ] + }, + { + "name": "string", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "string", + "kind": "keyword" + } + ] + }, + { + "name": "String", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "String", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "String", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "StringConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "Allows manipulation and formatting of text strings and determination and location of substrings within strings.", + "kind": "text" + } + ] + }, + { + "name": "super", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "super", + "kind": "keyword" + } + ] + }, + { + "name": "switch", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "switch", + "kind": "keyword" + } + ] + }, + { + "name": "symbol", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "symbol", + "kind": "keyword" + } + ] + }, + { + "name": "SyntaxError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SyntaxError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SyntaxError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SyntaxErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "this", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "this", + "kind": "keyword" + } + ] + }, + { + "name": "throw", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "throw", + "kind": "keyword" + } + ] + }, + { + "name": "true", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "true", + "kind": "keyword" + } + ] + }, + { + "name": "try", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "try", + "kind": "keyword" + } + ] + }, + { + "name": "type", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + } + ] + }, + { + "name": "TypeError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TypeError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TypeError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TypeErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "typeof", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "typeof", + "kind": "keyword" + } + ] + }, + { + "name": "Uint16Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint16Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint16Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint16ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Uint32Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint32Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint32Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint32ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Uint8Array", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8Array", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8Array", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the\nrequested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "Uint8ClampedArray", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ClampedArray", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ClampedArray", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Uint8ClampedArrayConstructor", + "kind": "interfaceName" + } + ], + "documentation": [ + { + "text": "A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.\nIf the requested number of bytes could not be allocated an exception is raised.", + "kind": "text" + } + ] + }, + { + "name": "undefined", + "kind": "var", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "undefined", + "kind": "propertyName" + } + ], + "documentation": [] + }, + { + "name": "unique", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "unique", + "kind": "keyword" + } + ] + }, + { + "name": "unknown", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "unknown", + "kind": "keyword" + } + ] + }, + { + "name": "URIError", + "kind": "var", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "URIError", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "URIError", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "URIErrorConstructor", + "kind": "interfaceName" + } + ], + "documentation": [] + }, + { + "name": "var", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "var", + "kind": "keyword" + } + ] + }, + { + "name": "void", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "void", + "kind": "keyword" + } + ] + }, + { + "name": "while", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "while", + "kind": "keyword" + } + ] + }, + { + "name": "with", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "with", + "kind": "keyword" + } + ] + }, + { + "name": "yield", + "kind": "keyword", + "kindModifiers": "", + "sortText": "15", + "displayParts": [ + { + "text": "yield", + "kind": "keyword" + } + ] + }, + { + "name": "escape", + "kind": "function", + "kindModifiers": "deprecated,declare", + "sortText": "z15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "escape", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence.", + "kind": "text" + } + ], + "tags": [ + { + "name": "deprecated", + "text": [ + { + "text": "A legacy feature for browser compatibility", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string value", + "kind": "text" + } + ] + } + ] + }, + { + "name": "unescape", + "kind": "function", + "kindModifiers": "deprecated,declare", + "sortText": "z15", + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "unescape", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents.", + "kind": "text" + } + ], + "tags": [ + { + "name": "deprecated", + "text": [ + { + "text": "A legacy feature for browser compatibility", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "string", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string value", + "kind": "text" + } + ] + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/completionInNamedImportLocation.ts b/tests/cases/fourslash/completionInNamedImportLocation.ts index 3ec4d07a701d0..962df8fec2dbc 100644 --- a/tests/cases/fourslash/completionInNamedImportLocation.ts +++ b/tests/cases/fourslash/completionInNamedImportLocation.ts @@ -3,6 +3,7 @@ // @Filename: file.ts ////export var x = 10; ////export var y = 10; +////export { x as "hello world", x as await }; ////export default class C { ////} @@ -10,22 +11,9 @@ // @Filename: a.ts ////import { /*1*/ } from "./file"; ////import { x, /*2*/ } from "./file"; +////import { x, y, /*3*/ } from "./file"; +////import { x, y, "hello world" as d, /*4*/ } from "./file"; +////import { x, y, "hello world" as d, await as await_, /*5*/ } from "./file"; goTo.file("a.ts"); -verify.completions( - { - marker: "1", - exact: [ - { name: "x", text: "var x: number" }, - { name: "y", text: "var y: number" }, - { name: "type", sortText: completion.SortText.GlobalsOrKeywords }, - ] - }, - { - marker: "2", - exact: [ - { name: "y", text: "var y: number" }, - { name: "type", sortText: completion.SortText.GlobalsOrKeywords }, - ] - }, -); +verify.baselineCompletions(); diff --git a/tests/cases/fourslash/completionListInExportClause01.ts b/tests/cases/fourslash/completionListInExportClause01.ts index 427d344930998..ed08e8682ce8f 100644 --- a/tests/cases/fourslash/completionListInExportClause01.ts +++ b/tests/cases/fourslash/completionListInExportClause01.ts @@ -4,6 +4,7 @@ ////export var foo: number = 1; ////export function bar() { return 10; } ////export function baz() { return 10; } +////export { foo as "hello world", foo as break } // @Filename: m2.ts ////export {/*1*/, /*2*/ from "./m1" @@ -11,13 +12,10 @@ ////export {foo,/*4*/ from "./m1" ////export {bar as /*5*/, /*6*/ from "./m1" ////export {foo, bar, baz as b,/*7*/} from "./m1" +////export {foo, bar, baz as b, "hello world" as d, /*8*/} from "./m1" +////export {foo, bar, baz as b, "hello world" as d, break as break_, /*9*/} from "./m1" const type = { name: "type", sortText: completion.SortText.GlobalsOrKeywords }; +const hello: FourSlashInterface.ExpectedCompletionEntry = { name: "hello world", insertText: `"hello world"` }; -verify.completions( - { marker: ["1", "2", "3"], exact: ["bar", "baz", "foo", type] }, - { marker: "4", exact: ["bar", "baz", type] }, - { marker: "5", exact: undefined, isNewIdentifierLocation: true }, - { marker: "6", exact: ["baz", "foo", type] }, - { marker: "7", exact: undefined }, -); +verify.baselineCompletions(); diff --git a/tests/cases/fourslash/completionListInImportClause04.ts b/tests/cases/fourslash/completionListInImportClause04.ts index 556f2ef1d734b..17987d9c18ada 100644 --- a/tests/cases/fourslash/completionListInImportClause04.ts +++ b/tests/cases/fourslash/completionListInImportClause04.ts @@ -5,12 +5,15 @@ //// static prop1(x: number): number; //// static prop1(x: string): string; //// static prop2(x: boolean): boolean; +//// static ['hello world']: boolean; //// } //// export = Foo; /*2*/ // @Filename: app.ts ////import {/*1*/} from './foo'; +// TODO: expected to have { name: "hello world", insertText: "'hello world' as ${1:item}" }, +// but Foo does not have a ValueModule flag even it is used as one. verify.completions({ marker: "1", unsorted: ["prototype", "prop1", "prop2", { name: "type", sortText: completion.SortText.GlobalsOrKeywords }] }); verify.noErrors(); goTo.marker('2'); diff --git a/tests/cases/fourslash/completionsImport_ambient.ts b/tests/cases/fourslash/completionsImport_ambient.ts index a7bc23a5a94de..402a53cdd22db 100644 --- a/tests/cases/fourslash/completionsImport_ambient.ts +++ b/tests/cases/fourslash/completionsImport_ambient.ts @@ -6,48 +6,16 @@ //// declare namespace foo { class Bar {} } //// declare module 'path1' { //// import Bar = foo.Bar; +//// export { Bar as "Bar non ident", Bar as await, Bar as break, Bar as unique }; //// export default Bar; //// } //// declare module 'path2longer' { //// import Bar = foo.Bar; -//// export {Bar}; +//// export { Bar as "Bar non ident", Bar as await, Bar as break, Bar as unique }; //// } //// // @Filename: b.ts -//// Ba/**/ +//// Ba/*1*/ -verify.completions({ - marker: "", - exact: completion.globalsPlus([ - { - name: "foo", - sortText: completion.SortText.GlobalsOrKeywords - }, - { - name: "Bar", - source: "path1", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions - }, - { - name: "Bar", - source: "path2longer", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions - }, - ]), - preferences: { - includeCompletionsForModuleExports: true - } -}); - -verify.applyCodeActionFromCompletion("", { - name: "Bar", - source: "path2longer", - description: `Add import from "path2longer"`, - newFileContent: `import { Bar } from "path2longer";\n\nBa`, - preferences: { - includeCompletionsForModuleExports: true - } -}); +verify.baselineCompletions(); diff --git a/tests/cases/fourslash/completionsImport_augmentation.ts b/tests/cases/fourslash/completionsImport_augmentation.ts index f01f7f43df1a1..246a5a5e46138 100644 --- a/tests/cases/fourslash/completionsImport_augmentation.ts +++ b/tests/cases/fourslash/completionsImport_augmentation.ts @@ -7,32 +7,10 @@ ////export {}; ////declare module "./a" { //// export const bar = 0; +//// export { bar as "Bar non ident", bar as break, bar as await, bar as unique } ////} // @Filename: /user.ts /////**/ -verify.completions({ - marker: "", - includes: [ - { - name: "foo", - text: "const foo: 0", - source: "/a", - sourceDisplay: "./a", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions - }, - { - name: "bar", - text: "const bar: 0", - source: "/a", - sourceDisplay: "./a", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions - }, - ], - preferences: { - includeCompletionsForModuleExports: true, - }, -}); +verify.baselineCompletions(); diff --git a/tests/cases/fourslash/completionsImport_fromAmbientModule.ts b/tests/cases/fourslash/completionsImport_fromAmbientModule.ts index 747dd50c77639..50a14a0ee3084 100644 --- a/tests/cases/fourslash/completionsImport_fromAmbientModule.ts +++ b/tests/cases/fourslash/completionsImport_fromAmbientModule.ts @@ -5,16 +5,10 @@ // @Filename: /a.ts ////declare module "m" { //// export const x: number; +//// export {x as "x ", x as break, x as await, x as unique}; ////} // @Filename: /b.ts /////**/ -verify.applyCodeActionFromCompletion("", { - name: "x", - source: "m", - description: `Add import from "m"`, - newFileContent: `import { x } from "m"; - -`, -}); +verify.baselineCompletions();