diff --git a/package-lock.json b/package-lock.json index ea7118978788e..d1b8b13ff5fb7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -638,13 +638,13 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.13", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", - "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^2.0.1", - "debug": "^4.1.1", + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", "minimatch": "^3.0.5" }, "engines": { @@ -687,9 +687,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", - "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, "node_modules/@istanbuljs/schema": { @@ -717,9 +717,9 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.20", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", - "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "version": "0.3.21", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz", + "integrity": "sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", @@ -1011,9 +1011,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.10.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.7.tgz", - "integrity": "sha512-fRbIKb8C/Y2lXxB5eVMj4IU7xpdox0Lh8bUPEdtLysaylsml1hOOx1+STloRs/B9nf7C6kPRmmg/V7aQW7usNg==", + "version": "20.11.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.1.tgz", + "integrity": "sha512-DsXojJUES2M+FE8CpptJTKpg+r54moV9ZEncPstni1WHFmTcCzeFLnMFfyhCVS8XNOy/OQG+8lVxRLRrVHmV5A==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -1353,9 +1353,9 @@ } }, "node_modules/azure-devops-node-api": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-12.1.0.tgz", - "integrity": "sha512-VY+G45eNKVJfMIO0uyZfbi4PzUR8JHEfsHQjEUAXUGRkYhhBbhGHjy8cpiyYFxLXc3a4PL5cqgqqV/YD1SaCXg==", + "version": "12.3.0", + "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-12.3.0.tgz", + "integrity": "sha512-5HDhBFIXJxiFhcJ+A3hN87gwo92PrDNLJvcvRHjr+p7AsuUSF64yQU+M6wcBDczkIDVV7m+MrraKQ2tqUxSbCA==", "dev": true, "dependencies": { "tunnel": "0.0.6", @@ -1478,9 +1478,9 @@ } }, "node_modules/chai": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.0.tgz", - "integrity": "sha512-x9cHNq1uvkCdU+5xTkNh5WtgD4e4yDFCsp9jVc7N7qVeKeftv3gO/ZrviX5d+3ZfxdYnZXZYujjRInu1RogU6A==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", + "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==", "dev": true, "dependencies": { "assertion-error": "^1.1.0", @@ -2153,9 +2153,9 @@ "dev": true }, "node_modules/fast-xml-parser": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.2.tgz", - "integrity": "sha512-rmrXUXwbJedoXkStenj1kkljNF7ugn5ZjR9FJcwmCfcCbtOMDghPajbc+Tck6vE6F5XsDmx+Pr2le9fw8+pXBg==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.3.tgz", + "integrity": "sha512-coV/D1MhrShMvU6D0I+VAK3umz6hUaxxhL0yp/9RjfiYUfAv14rDhGQL+PLForhMdr0wq3PiV07WtkkNjJjNHg==", "dev": true, "funding": [ { @@ -3602,15 +3602,16 @@ } }, "node_modules/set-function-length": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", - "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", + "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", "dev": true, "dependencies": { "define-data-property": "^1.1.1", - "get-intrinsic": "^1.2.1", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.2", "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "has-property-descriptors": "^1.0.1" }, "engines": { "node": ">= 0.4" @@ -4431,13 +4432,13 @@ "dev": true }, "@humanwhocodes/config-array": { - "version": "0.11.13", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", - "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "requires": { - "@humanwhocodes/object-schema": "^2.0.1", - "debug": "^4.1.1", + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", "minimatch": "^3.0.5" }, "dependencies": { @@ -4469,9 +4470,9 @@ "dev": true }, "@humanwhocodes/object-schema": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", - "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, "@istanbuljs/schema": { @@ -4493,9 +4494,9 @@ "dev": true }, "@jridgewell/trace-mapping": { - "version": "0.3.20", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", - "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "version": "0.3.21", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz", + "integrity": "sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g==", "dev": true, "requires": { "@jridgewell/resolve-uri": "^3.1.0", @@ -4736,9 +4737,9 @@ "dev": true }, "@types/node": { - "version": "20.10.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.7.tgz", - "integrity": "sha512-fRbIKb8C/Y2lXxB5eVMj4IU7xpdox0Lh8bUPEdtLysaylsml1hOOx1+STloRs/B9nf7C6kPRmmg/V7aQW7usNg==", + "version": "20.11.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.1.tgz", + "integrity": "sha512-DsXojJUES2M+FE8CpptJTKpg+r54moV9ZEncPstni1WHFmTcCzeFLnMFfyhCVS8XNOy/OQG+8lVxRLRrVHmV5A==", "dev": true, "requires": { "undici-types": "~5.26.4" @@ -4953,9 +4954,9 @@ "dev": true }, "azure-devops-node-api": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-12.1.0.tgz", - "integrity": "sha512-VY+G45eNKVJfMIO0uyZfbi4PzUR8JHEfsHQjEUAXUGRkYhhBbhGHjy8cpiyYFxLXc3a4PL5cqgqqV/YD1SaCXg==", + "version": "12.3.0", + "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-12.3.0.tgz", + "integrity": "sha512-5HDhBFIXJxiFhcJ+A3hN87gwo92PrDNLJvcvRHjr+p7AsuUSF64yQU+M6wcBDczkIDVV7m+MrraKQ2tqUxSbCA==", "dev": true, "requires": { "tunnel": "0.0.6", @@ -5054,9 +5055,9 @@ "dev": true }, "chai": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.0.tgz", - "integrity": "sha512-x9cHNq1uvkCdU+5xTkNh5WtgD4e4yDFCsp9jVc7N7qVeKeftv3gO/ZrviX5d+3ZfxdYnZXZYujjRInu1RogU6A==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", + "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==", "dev": true, "requires": { "assertion-error": "^1.1.0", @@ -5572,9 +5573,9 @@ "dev": true }, "fast-xml-parser": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.2.tgz", - "integrity": "sha512-rmrXUXwbJedoXkStenj1kkljNF7ugn5ZjR9FJcwmCfcCbtOMDghPajbc+Tck6vE6F5XsDmx+Pr2le9fw8+pXBg==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.3.tgz", + "integrity": "sha512-coV/D1MhrShMvU6D0I+VAK3umz6hUaxxhL0yp/9RjfiYUfAv14rDhGQL+PLForhMdr0wq3PiV07WtkkNjJjNHg==", "dev": true, "requires": { "strnum": "^1.0.5" @@ -6566,15 +6567,16 @@ } }, "set-function-length": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", - "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", + "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", "dev": true, "requires": { "define-data-property": "^1.1.1", - "get-intrinsic": "^1.2.1", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.2", "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "has-property-descriptors": "^1.0.1" } }, "shebang-command": { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e5928748bbd60..50a47ad892537 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -325,6 +325,7 @@ import { getModeForUsageLocation, getModifiers, getModuleInstanceState, + getNameFromImportAttribute, getNameFromIndexInfo, getNameOfDeclaration, getNameOfExpando, @@ -407,6 +408,7 @@ import { IdentifierTypePredicate, idText, IfStatement, + ImportAttribute, ImportAttributes, ImportCall, ImportClause, @@ -553,6 +555,7 @@ import { isIdentifierTypePredicate, isIdentifierTypeReference, isIfStatement, + isImportAttributes, isImportCall, isImportClause, isImportDeclaration, @@ -872,7 +875,6 @@ import { NonNullExpression, not, noTruncationMaximumTruncationLength, - nullTransformationContext, NumberLiteralType, NumericLiteral, objectAllocator, @@ -1364,6 +1366,7 @@ const enum IntrinsicTypeKind { Lowercase, Capitalize, Uncapitalize, + NoInfer, } const intrinsicTypeKinds: ReadonlyMap = new Map(Object.entries({ @@ -1371,6 +1374,7 @@ const intrinsicTypeKinds: ReadonlyMap = new Map(Objec Lowercase: IntrinsicTypeKind.Lowercase, Capitalize: IntrinsicTypeKind.Capitalize, Uncapitalize: IntrinsicTypeKind.Uncapitalize, + NoInfer: IntrinsicTypeKind.NoInfer, })); const SymbolLinks = class implements SymbolLinks { @@ -2179,6 +2183,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var deferredGlobalImportMetaType: ObjectType; var deferredGlobalImportMetaExpressionType: ObjectType; var deferredGlobalImportCallOptionsType: ObjectType | undefined; + var deferredGlobalImportAttributesType: ObjectType | undefined; var deferredGlobalDisposableType: ObjectType | undefined; var deferredGlobalAsyncDisposableType: ObjectType | undefined; var deferredGlobalExtractSymbol: Symbol | undefined; @@ -2361,7 +2366,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function markAsSynthetic(node: T): VisitResult { setTextRangePosEnd(node, -1, -1); - return visitEachChild(node, markAsSynthetic, nullTransformationContext); + return visitEachChild(node, markAsSynthetic, /*context*/ undefined); } function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken) { @@ -5719,6 +5724,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { * Checks if two symbols, through aliasing and/or merging, refer to the same thing */ function getSymbolIfSameReference(s1: Symbol, s2: Symbol) { + if (s1.flags & SymbolFlags.TypeAlias && s2.declarations?.find(isTypeAlias)) { + s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2; + } + if (s2.flags & SymbolFlags.TypeAlias && s1.declarations?.find(isTypeAlias)) { + s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1; + } if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { return s1; } @@ -6216,16 +6227,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function hasVisibleDeclarations(symbol: Symbol, shouldComputeAliasToMakeVisible: boolean): SymbolVisibilityResult | undefined { let aliasesToMakeVisible: LateVisibilityPaintedStatement[] | undefined; - let bindingElementToMakeVisible: BindingElement | undefined; if (!every(filter(symbol.declarations, d => d.kind !== SyntaxKind.Identifier), getIsDeclarationVisible)) { return undefined; } - return { accessibility: SymbolAccessibility.Accessible, aliasesToMakeVisible, bindingElementToMakeVisible }; + return { accessibility: SymbolAccessibility.Accessible, aliasesToMakeVisible }; function getIsDeclarationVisible(declaration: Declaration) { - if (isBindingElement(declaration) && findAncestor(declaration, isParameter)) { - bindingElementToMakeVisible = declaration; - } if (!isDeclarationVisible(declaration)) { // Mark the unexported alias as visible if its parent is visible // because these kind of aliases can be used to name types in declaration file @@ -6744,7 +6751,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return visitAndTransformType(type, type => conditionalTypeToTypeNode(type as ConditionalType)); } if (type.flags & TypeFlags.Substitution) { - return typeToTypeNodeHelper((type as SubstitutionType).baseType, context); + const typeNode = typeToTypeNodeHelper((type as SubstitutionType).baseType, context); + const noInferSymbol = isNoInferType(type) && getGlobalTypeSymbol("NoInfer" as __String, /*reportErrors*/ false); + return noInferSymbol ? symbolToTypeNode(noInferSymbol, context, SymbolFlags.Type, [typeNode]) : typeNode; } return Debug.fail("Should be unreachable."); @@ -7022,7 +7031,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!nodeIsSynthesized(node) && getParseTreeNode(node) === node) { return node; } - return setTextRange(factory.cloneNode(visitEachChild(node, deepCloneOrReuseNode, nullTransformationContext, deepCloneOrReuseNodes)), node); + return setTextRange(factory.cloneNode(visitEachChild(node, deepCloneOrReuseNode, /*context*/ undefined, deepCloneOrReuseNodes)), node); } function deepCloneOrReuseNodes( @@ -7816,7 +7825,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (context.tracker.canTrackSymbol && isComputedPropertyName(node) && isLateBindableName(node)) { trackComputedName(node.expression, context.enclosingDeclaration, context); } - let visited = visitEachChild(node, elideInitializerAndSetEmitFlags, nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags)!; + let visited = visitEachChild(node, elideInitializerAndSetEmitFlags, /*context*/ undefined, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags)!; if (isBindingElement(visited)) { visited = factory.updateBindingElement( visited, @@ -8653,7 +8662,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { setEmitFlags(node, EmitFlags.SingleLine); } - return visitEachChild(node, visitExistingNodeTreeSymbols, nullTransformationContext); + return visitEachChild(node, visitExistingNodeTreeSymbols, /*context*/ undefined); function getEffectiveDotDotDotForParameter(p: ParameterDeclaration) { return p.dotDotDotToken || (p.type && isJSDocVariadicType(p.type) ? factory.createToken(SyntaxKind.DotDotDotToken) : undefined); @@ -8748,7 +8757,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { }); let addingDeclare = !bundled; const exportEquals = symbolTable.get(InternalSymbolName.ExportEquals); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & SymbolFlags.Alias) { + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & (SymbolFlags.Alias | SymbolFlags.Module)) { symbolTable = createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) symbolTable.set(InternalSymbolName.ExportEquals, exportEquals); @@ -9281,8 +9290,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getNamespaceMembersForSerialization(symbol: Symbol) { - const exports = getExportsOfSymbol(symbol); - return !exports ? [] : filter(arrayFrom(exports.values()), m => isNamespaceMember(m) && isIdentifierText(m.escapedName as string, ScriptTarget.ESNext)); + let exports = arrayFrom(getExportsOfSymbol(symbol).values()); + const merged = getMergedSymbol(symbol); + if (merged !== symbol) { + const membersSet = new Set(exports); + for (const exported of getExportsOfSymbol(merged).values()) { + if (!(getSymbolFlags(resolveSymbol(exported)) & SymbolFlags.Value)) { + membersSet.add(exported); + } + } + exports = arrayFrom(membersSet); + } + return filter(exports, m => isNamespaceMember(m) && isIdentifierText(m.escapedName as string, ScriptTarget.ESNext)); } function isTypeOnlyNamespace(symbol: Symbol) { @@ -11454,7 +11473,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. const contextualType = isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, CheckMode.Normal, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors ? CheckMode.Normal : CheckMode.Contextual, contextualType))); } if (isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -11549,6 +11568,25 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, CheckMode.Normal), declaration, reportErrors); } + function getTypeFromImportAttributes(node: ImportAttributes): Type { + const links = getNodeLinks(node); + if (!links.resolvedType) { + const symbol = createSymbol(SymbolFlags.ObjectLiteral, InternalSymbolName.ImportAttributes); + const members = createSymbolTable(); + forEach(node.elements, attr => { + const member = createSymbol(SymbolFlags.Property, getNameFromImportAttribute(attr)); + member.parent = symbol; + member.links.type = checkImportAttribute(attr); + member.links.target = member; + members.set(member.escapedName, member); + }); + const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray); + type.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.NonInferrableType; + links.resolvedType = type; + } + return links.resolvedType; + } + function isGlobalSymbolConstructor(node: Node) { const symbol = getSymbolOfNode(node); const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(/*reportErrors*/ false); @@ -11612,16 +11650,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return false; } - function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type { + function getTypeOfVariableOrParameterOrProperty(symbol: Symbol, checkMode?: CheckMode): Type { const links = getSymbolLinks(symbol); if (!links.type) { - const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol); + const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode); // For a contextually typed parameter it is possible that a type has already // been assigned (in assignTypeToParameterAndFixTypeParameters), and we want // to preserve this type. In fact, we need to _prefer_ that type, but it won't // be assigned until contextual typing is complete, so we need to defer in // cases where contextual typing may take place. - if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) { + if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) { links.type = type; } return type; @@ -11629,7 +11667,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return links.type; } - function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol): Type { + function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol, checkMode?: CheckMode): Type { // Handle prototype property if (symbol.flags & SymbolFlags.Prototype) { return getTypeOfPrototypeProperty(symbol); @@ -11672,6 +11710,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) { return getTypeOfFuncClassEnumModule(symbol); } + + // When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore + // end up in a circularity-like situation. This is not a true circularity so we should not report such an error. + // For example, here the looping could happen when trying to get the type of `a` (binding element): + // + // const { a, b = a } = { a: 0 } + // + if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) { + return errorType; + } return reportCircularityError(symbol); } let type: Type; @@ -11744,6 +11792,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) { return getTypeOfFuncClassEnumModule(symbol); } + + // When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore + // end up in a circularity-like situation. This is not a true circularity so we should not report such an error. + // For example, here the looping could happen when trying to get the type of `a` (binding element): + // + // const { a, b = a } = { a: 0 } + // + if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) { + return type; + } return reportCircularityError(symbol); } return type; @@ -12026,7 +12084,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return getTypeOfSymbol(symbol); } - function getTypeOfSymbol(symbol: Symbol): Type { + function getTypeOfSymbol(symbol: Symbol, checkMode?: CheckMode): Type { const checkFlags = getCheckFlags(symbol); if (checkFlags & CheckFlags.DeferredType) { return getTypeOfSymbolWithDeferredType(symbol); @@ -12041,7 +12099,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return getTypeOfReverseMappedSymbol(symbol as ReverseMappedSymbol); } if (symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property)) { - return getTypeOfVariableOrParameterOrProperty(symbol); + return getTypeOfVariableOrParameterOrProperty(symbol, checkMode); } if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) { return getTypeOfFuncClassEnumModule(symbol); @@ -15921,8 +15979,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function getTypeAliasInstantiation(symbol: Symbol, typeArguments: readonly Type[] | undefined, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): Type { const type = getDeclaredTypeOfSymbol(symbol); - if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName as string) && typeArguments && typeArguments.length === 1) { - return getStringMappingType(symbol, typeArguments[0]); + if (type === intrinsicMarkerType) { + const typeKind = intrinsicTypeKinds.get(symbol.escapedName as string); + if (typeKind !== undefined && typeArguments && typeArguments.length === 1) { + return typeKind === IntrinsicTypeKind.NoInfer ? getNoInferType(typeArguments[0]) : getStringMappingType(symbol, typeArguments[0]); + } } const links = getSymbolLinks(symbol); const typeParameters = links.typeParameters!; @@ -16104,10 +16165,32 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return links.resolvedJSDocType; } + function getNoInferType(type: Type) { + return isNoInferTargetType(type) ? getOrCreateSubstitutionType(type, unknownType) : type; + } + + function isNoInferTargetType(type: Type): boolean { + // This is effectively a more conservative and predictable form of couldContainTypeVariables. We want to + // preserve NoInfer only for types that could contain type variables, but we don't want to exhaustively + // examine all object type members. + return !!(type.flags & TypeFlags.UnionOrIntersection && some((type as UnionOrIntersectionType).types, isNoInferTargetType) || + type.flags & TypeFlags.Substitution && !isNoInferType(type) && isNoInferTargetType((type as SubstitutionType).baseType) || + type.flags & TypeFlags.Object && !isEmptyAnonymousObjectType(type) || + type.flags & (TypeFlags.Instantiable & ~TypeFlags.Substitution) && !isPatternLiteralType(type)); + } + + function isNoInferType(type: Type) { + // A NoInfer type is represented as a substitution type with a TypeFlags.Unknown constraint. + return !!(type.flags & TypeFlags.Substitution && (type as SubstitutionType).constraint.flags & TypeFlags.Unknown); + } + function getSubstitutionType(baseType: Type, constraint: Type) { - if (constraint.flags & TypeFlags.AnyOrUnknown || constraint === baseType || baseType.flags & TypeFlags.Any) { - return baseType; - } + return constraint.flags & TypeFlags.AnyOrUnknown || constraint === baseType || baseType.flags & TypeFlags.Any ? + baseType : + getOrCreateSubstitutionType(baseType, constraint); + } + + function getOrCreateSubstitutionType(baseType: Type, constraint: Type) { const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`; const cached = substitutionTypes.get(id); if (cached) { @@ -16121,7 +16204,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getSubstitutionIntersection(substitutionType: SubstitutionType) { - return getIntersectionType([substitutionType.constraint, substitutionType.baseType]); + return isNoInferType(substitutionType) ? substitutionType.baseType : getIntersectionType([substitutionType.constraint, substitutionType.baseType]); } function isUnaryTupleTypeNode(node: TypeNode) { @@ -16391,6 +16474,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return (deferredGlobalImportCallOptionsType ||= getGlobalType("ImportCallOptions" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType; } + function getGlobalImportAttributesType(reportErrors: boolean) { + return (deferredGlobalImportAttributesType ||= getGlobalType("ImportAttributes" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType; + } + function getGlobalESSymbolConstructorSymbol(reportErrors: boolean): Symbol | undefined { return deferredGlobalESSymbolConstructorSymbol ||= getGlobalValueSymbol("Symbol" as __String, reportErrors); } @@ -17795,7 +17882,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function getIndexType(type: Type, indexFlags = defaultIndexFlags): Type { type = getReducedType(type); - return shouldDeferIndexType(type, indexFlags) ? getIndexTypeForGenericType(type as InstantiableType | UnionOrIntersectionType, indexFlags) : + return isNoInferType(type) ? getNoInferType(getIndexType((type as SubstitutionType).baseType, indexFlags)) : + shouldDeferIndexType(type, indexFlags) ? getIndexTypeForGenericType(type as InstantiableType | UnionOrIntersectionType, indexFlags) : type.flags & TypeFlags.Union ? getIntersectionType(map((type as UnionType).types, t => getIndexType(t, indexFlags))) : type.flags & TypeFlags.Intersection ? getUnionType(map((type as IntersectionType).types, t => getIndexType(t, indexFlags))) : getObjectFlags(type) & ObjectFlags.Mapped ? getIndexTypeForMappedType(type as MappedType, indexFlags) : @@ -19883,6 +19971,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (flags & TypeFlags.Substitution) { const newBaseType = instantiateType((type as SubstitutionType).baseType, mapper); + if (isNoInferType(type)) { + return getNoInferType(newBaseType); + } const newConstraint = instantiateType((type as SubstitutionType).constraint, mapper); // A substitution type originates in the true branch of a conditional type and can be resolved // to just the base type in the same cases as the conditional type resolves to its true branch @@ -25401,7 +25492,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { inferFromTypes(originalSource, originalTarget); function inferFromTypes(source: Type, target: Type): void { - if (!couldContainTypeVariables(target)) { + if (!couldContainTypeVariables(target) || isNoInferType(target)) { return; } if (source === wildcardType || source === blockedStringType) { @@ -25474,6 +25565,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } if (target.flags & (TypeFlags.IndexedAccess | TypeFlags.Substitution)) { + if (isNoInferType(target)) { + return; + } target = getActualTypeVariable(target); } if (target.flags & TypeFlags.TypeVariable) { @@ -29063,8 +29157,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function getNarrowedTypeOfSymbol(symbol: Symbol, location: Identifier) { - const type = getTypeOfSymbol(symbol); + function getNarrowedTypeOfSymbol(symbol: Symbol, location: Identifier, checkMode?: CheckMode) { + const type = getTypeOfSymbol(symbol, checkMode); const declaration = symbol.valueDeclaration; if (declaration) { // If we have a non-rest binding element with no initializer declared as a const variable or a const-like @@ -29227,7 +29321,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { checkNestedBlockScopedBinding(node, symbol); - let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); + let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode); const assignmentKind = getAssignmentTargetKind(node); if (assignmentKind) { @@ -30878,6 +30972,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxSelfClosingElement: return getContextualJsxElementAttributesType(parent as JsxOpeningLikeElement, contextFlags); + case SyntaxKind.ImportAttribute: + return getContextualImportAttributeType(parent as ImportAttribute); } return undefined; } @@ -30924,6 +31020,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } + function getContextualImportAttributeType(node: ImportAttribute) { + return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(/*reportErrors*/ false), getNameFromImportAttribute(node)); + } + function getContextualJsxElementAttributesType(node: JsxOpeningLikeElement, contextFlags: ContextFlags | undefined) { if (isJsxOpeningElement(node) && contextFlags !== ContextFlags.Completions) { const index = findContextualNode(node.parent, /*includeCaches*/ !contextFlags); @@ -45965,6 +46065,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function checkImportAttributes(declaration: ImportDeclaration | ExportDeclaration) { const node = declaration.attributes; if (node) { + const importAttributesType = getGlobalImportAttributesType(/*reportErrors*/ true); + if (importAttributesType !== emptyObjectType) { + checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, TypeFlags.Undefined), node); + } + const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration); const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : undefined); const isImportAttributes = declaration.attributes.token === SyntaxKind.WithKeyword; @@ -45994,6 +46099,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } + function checkImportAttribute(node: ImportAttribute) { + return getRegularTypeOfLiteralType(checkExpressionCached(node.value)); + } + function checkImportDeclaration(node: ImportDeclaration) { if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) { // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. @@ -47674,6 +47783,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return checkMetaPropertyKeyword(node.parent); } + if (isImportAttributes(node)) { + return getGlobalImportAttributesType(/*reportErrors*/ false); + } + return errorType; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6d29b82bed704..58c43f7411985 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -218,7 +218,7 @@ const libEntries: [string, string][] = [ ["es2023.array", "lib.es2023.array.d.ts"], ["es2023.collection", "lib.es2023.collection.d.ts"], ["esnext.array", "lib.es2023.array.d.ts"], - ["esnext.collection", "lib.es2023.collection.d.ts"], + ["esnext.collection", "lib.esnext.collection.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], @@ -228,6 +228,7 @@ const libEntries: [string, string][] = [ ["esnext.promise", "lib.esnext.promise.d.ts"], ["esnext.weakref", "lib.es2021.weakref.d.ts"], ["esnext.decorators", "lib.esnext.decorators.d.ts"], + ["esnext.object", "lib.esnext.object.d.ts"], ["decorators", "lib.decorators.d.ts"], ["decorators.legacy", "lib.decorators.legacy.d.ts"], ]; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 067b66dca5714..6dd6cb6de43fe 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -254,6 +254,7 @@ import { parseJsonSourceFileConfigFileContent, parseNodeFactory, Path, + pathContainsNodeModules, pathIsAbsolute, pathIsRelative, Program, @@ -4039,7 +4040,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const isFromNodeModulesSearch = resolution.isExternalLibraryImport; const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension); - const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile; + const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName)); const resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index be0d973032edf..32d7af09c03e7 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1445,6 +1445,7 @@ export interface System { realpath?(path: string): string; /** @internal */ getEnvironmentVariable(name: string): string; /** @internal */ tryEnableSourceMapsForHost?(): void; + /** @internal */ getAccessibleFileSystemEntries?(path: string): FileSystemEntries; /** @internal */ debugMode?: boolean; setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; clearTimeout?(timeoutId: any): void; @@ -1553,6 +1554,7 @@ export let sys: System = (() => { resolvePath: path => _path.resolve(path), fileExists, directoryExists, + getAccessibleFileSystemEntries, createDirectory(directoryName: string) { if (!nodeSystem.directoryExists(directoryName)) { // Wrapped in a try-catch to prevent crashing if we are in a race diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 95bcc19820ff0..0a9e58c6de3b8 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -14,7 +14,6 @@ import { canHaveModifiers, canProduceDiagnostics, ClassDeclaration, - CommentRange, compact, concatenate, ConditionalTypeNode, @@ -47,12 +46,10 @@ import { factory, FileReference, filter, - findAncestor, flatMap, flatten, forEach, FunctionDeclaration, - FunctionExpression, FunctionTypeNode, GeneratedIdentifierFlags, GetAccessorDeclaration, @@ -63,12 +60,9 @@ import { getExternalModuleImportEqualsDeclarationExpression, getExternalModuleNameFromDeclaration, getFirstConstructorWithBody, - getLeadingCommentRanges, - getLeadingCommentRangesOfNode, getLineAndCharacterOfPosition, getNameOfDeclaration, getNormalizedAbsolutePath, - getOriginalNode, getOriginalNodeId, getOutputPathsFor, getParseTreeNode, @@ -80,7 +74,6 @@ import { GetSymbolAccessibilityDiagnostic, getTextOfNode, getThisParameter, - getTrailingCommentRanges, hasDynamicName, hasEffectiveModifier, hasExtension, @@ -119,13 +112,12 @@ import { isFunctionDeclaration, isFunctionLike, isGlobalScopeAugmentation, - isIdentifier, - isIdentifierANonContextualKeyword, isIdentifierText, isImportDeclaration, isImportEqualsDeclaration, isIndexSignatureDeclaration, isInterfaceDeclaration, + isInternalDeclaration, isJsonSourceFile, isLateVisibilityPaintedStatement, isLiteralImportTypeNode, @@ -135,7 +127,6 @@ import { isModifier, isModuleDeclaration, isOmittedExpression, - isParameter, isPrivateIdentifier, isPropertySignature, isSemicolonClassElement, @@ -157,8 +148,6 @@ import { isVarAwaitUsing, isVariableDeclaration, isVarUsing, - JSDocFunctionType, - last, LateBoundDeclaration, LateVisibilityPaintedStatement, length, @@ -189,7 +178,6 @@ import { pathContainsNodeModules, pathIsRelative, PropertyDeclaration, - PropertyName, PropertySignature, pushIfUnique, removeAllComments, @@ -201,8 +189,6 @@ import { setOriginalNode, setParent, setTextRange, - SignatureDeclaration, - skipTrivia, some, SourceFile, startsWith, @@ -243,35 +229,6 @@ export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver return result.diagnostics; } -function hasInternalAnnotation(range: CommentRange, currentSourceFile: SourceFile) { - const comment = currentSourceFile.text.substring(range.pos, range.end); - return comment.includes("@internal"); -} - -/** @internal */ -export function isInternalDeclaration(node: Node, currentSourceFile: SourceFile) { - const parseTreeNode = getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === SyntaxKind.Parameter) { - const paramIdx = (parseTreeNode.parent as SignatureDeclaration).parameters.indexOf(parseTreeNode as ParameterDeclaration); - const previousSibling = paramIdx > 0 ? (parseTreeNode.parent as SignatureDeclaration).parameters[paramIdx - 1] : undefined; - const text = currentSourceFile.text; - const commentRanges = previousSibling - ? concatenate( - // to handle - // ... parameters, /** @internal */ - // public param: string - getTrailingCommentRanges(text, skipTrivia(text, previousSibling.end + 1, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true)), - getLeadingCommentRanges(text, node.pos), - ) - : getTrailingCommentRanges(text, skipTrivia(text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true)); - return commentRanges && commentRanges.length && hasInternalAnnotation(last(commentRanges), currentSourceFile); - } - const leadingCommentRanges = parseTreeNode && getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile); - return !!forEach(leadingCommentRanges, range => { - return hasInternalAnnotation(range, currentSourceFile); - }); -} - const declarationEmitNodeBuilderFlags = NodeBuilderFlags.MultilineObjectLiterals | NodeBuilderFlags.WriteClassExpressionAsTypeLiteral | NodeBuilderFlags.UseTypeOfFunction | @@ -302,7 +259,6 @@ export function transformDeclarations(context: TransformationContext) { let lateStatementReplacementMap: Map>; let suppressNewDiagnosticContexts: boolean; let exportedModulesFromDeclarationEmit: Symbol[] | undefined; - const usedBindingElementAliases = new Map>(); const { factory } = context; const host = context.getEmitHost(); @@ -378,18 +334,6 @@ export function transformDeclarations(context: TransformationContext) { } } } - if (symbolAccessibilityResult.bindingElementToMakeVisible) { - const bindingElement = symbolAccessibilityResult.bindingElementToMakeVisible; - const parameter = findAncestor(bindingElement, isParameter); - Debug.assert(parameter !== undefined); - const parent = getOriginalNode(parameter.parent); - let aliases = usedBindingElementAliases.get(parent); - if (!aliases) { - usedBindingElementAliases.set(parent, aliases = new Map()); - } - aliases.set(getOriginalNode(bindingElement), bindingElement.name); - } - // TODO: Do all these accessibility checks inside/after the first pass in the checker when declarations are enabled, if possible } else { @@ -710,7 +654,7 @@ export function transformDeclarations(context: TransformationContext) { return ret; } - function filterBindingPatternInitializersAndRenamings(name: BindingName) { + function filterBindingPatternInitializers(name: BindingName) { if (name.kind === SyntaxKind.Identifier) { return name; } @@ -732,191 +676,15 @@ export function transformDeclarations(context: TransformationContext) { checkEntityNameVisibility(elem.propertyName.expression, enclosingDeclaration); } - if (elem.propertyName && isIdentifier(elem.propertyName) && isIdentifier(elem.name) && !isIdentifierANonContextualKeyword(elem.propertyName)) { - // Remove rename. We will add it back if it used. - return factory.updateBindingElement( - elem, - elem.dotDotDotToken, - /*propertyName*/ undefined, - elem.propertyName, - shouldPrintWithInitializer(elem) ? elem.initializer : undefined, - ); - } - return factory.updateBindingElement( elem, elem.dotDotDotToken, elem.propertyName, - filterBindingPatternInitializersAndRenamings(elem.name), + filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined, ); } } - type SignatureDeclarationWithUsableBindingAliases = Exclude; - function ensureBindingAliasesInParameterList(input: T, updatedNode: T): T; - function ensureBindingAliasesInParameterList(input: SignatureDeclarationWithUsableBindingAliases, updatedNode: SignatureDeclarationWithUsableBindingAliases) { - const original = getOriginalNode(input); - const params = updatedNode.parameters; - const aliases = usedBindingElementAliases.get(original); - if (!aliases) { - return updatedNode; - } - usedBindingElementAliases.delete(original); - const newParams = map(params, addUsedBindingPatternsToParameter); - const newParamsNodeArray = factory.createNodeArray(newParams, params.hasTrailingComma); - switch (updatedNode.kind) { - case SyntaxKind.MethodDeclaration: - return factory.updateMethodDeclaration( - updatedNode, - updatedNode.modifiers, - updatedNode.asteriskToken, - updatedNode.name, - updatedNode.questionToken, - updatedNode.typeParameters, - newParamsNodeArray, - updatedNode.type, - updatedNode.body, - ); - case SyntaxKind.Constructor: - return factory.updateConstructorDeclaration( - updatedNode, - updatedNode.modifiers, - newParamsNodeArray, - updatedNode.body, - ); - case SyntaxKind.GetAccessor: - return factory.updateGetAccessorDeclaration( - updatedNode, - updatedNode.modifiers, - updatedNode.name, - newParamsNodeArray, - updatedNode.type, - updatedNode.body, - ); - case SyntaxKind.SetAccessor: - return factory.updateSetAccessorDeclaration( - updatedNode, - updatedNode.modifiers, - updatedNode.name, - newParamsNodeArray, - updatedNode.body, - ); - case SyntaxKind.ArrowFunction: - return factory.updateArrowFunction( - updatedNode, - updatedNode.modifiers, - updatedNode.typeParameters, - newParamsNodeArray, - updatedNode.type, - updatedNode.equalsGreaterThanToken, - updatedNode.body, - ); - case SyntaxKind.FunctionDeclaration: - return factory.updateFunctionDeclaration( - updatedNode, - updatedNode.modifiers, - updatedNode.asteriskToken, - updatedNode.name, - updatedNode.typeParameters, - newParamsNodeArray, - updatedNode.type, - updatedNode.body, - ); - case SyntaxKind.CallSignature: - return factory.updateCallSignature( - updatedNode, - updatedNode.typeParameters, - newParamsNodeArray, - updatedNode.type, - ); - case SyntaxKind.MethodSignature: - return factory.updateMethodSignature( - updatedNode, - updatedNode.modifiers, - updatedNode.name, - updatedNode.questionToken, - updatedNode.typeParameters, - newParamsNodeArray, - updatedNode.type, - ); - - case SyntaxKind.ConstructSignature: - return factory.updateConstructSignature( - updatedNode, - updatedNode.typeParameters, - newParamsNodeArray, - updatedNode.type, - ); - case SyntaxKind.FunctionType: - return factory.updateFunctionTypeNode( - updatedNode, - updatedNode.typeParameters, - newParamsNodeArray, - updatedNode.type, - ); - case SyntaxKind.ConstructorType: - return factory.updateConstructorTypeNode( - updatedNode, - updatedNode.modifiers, - updatedNode.typeParameters, - newParamsNodeArray, - updatedNode.type, - ); - default: - Debug.assertNever(updatedNode); - } - - function addUsedBindingPatternsToParameter(p: ParameterDeclaration): ParameterDeclaration { - return factory.updateParameterDeclaration( - p, - p.modifiers, - p.dotDotDotToken, - addUsedBindingPatternAliases(p.name), - p.questionToken, - p.type, - p.initializer, - ); - } - function addUsedBindingPatternAliases(name: BindingName) { - if (name.kind === SyntaxKind.Identifier) { - return name; - } - else { - if (name.kind === SyntaxKind.ArrayBindingPattern) { - return factory.updateArrayBindingPattern(name, visitNodes(name.elements, visitBindingElement, isArrayBindingElement)); - } - else { - return factory.updateObjectBindingPattern(name, visitNodes(name.elements, visitBindingElement, isBindingElement)); - } - } - - function visitBindingElement(elem: T): T; - function visitBindingElement(elem: ArrayBindingElement): ArrayBindingElement { - if (elem.kind === SyntaxKind.OmittedExpression) { - return elem; - } - const usedAlias = aliases!.get(getOriginalNode(elem)); - // If alias is used and property name was removed by filterBindingPatternInitializersAndRenamings - // The alias can be preserved if it is a non contextual keyword. - if (usedAlias && !elem.propertyName) { - return factory.updateBindingElement( - elem, - elem.dotDotDotToken, - elem.name as PropertyName, - usedAlias, - elem.initializer, - ); - } - return factory.updateBindingElement( - elem, - elem.dotDotDotToken, - elem.propertyName, - addUsedBindingPatternAliases(elem.name), - elem.initializer, - ); - } - } - } function ensureParameter(p: ParameterDeclaration, modifierMask?: ModifierFlags, type?: TypeNode): ParameterDeclaration { let oldDiag: typeof getSymbolAccessibilityDiagnostic | undefined; @@ -928,7 +696,7 @@ export function transformDeclarations(context: TransformationContext) { p, maskModifiers(factory, p, modifierMask), p.dotDotDotToken, - filterBindingPatternInitializersAndRenamings(p.name), + filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(SyntaxKind.QuestionToken)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p), @@ -1367,24 +1135,18 @@ export function transformDeclarations(context: TransformationContext) { return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } case SyntaxKind.ConstructSignature: - return cleanup(ensureBindingAliasesInParameterList( + return cleanup(factory.updateConstructSignature( input, - factory.updateConstructSignature( - input, - ensureTypeParams(input, input.typeParameters), - updateParamsList(input, input.parameters), - ensureType(input, input.type), - ), + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters), + ensureType(input, input.type), )); case SyntaxKind.Constructor: { // A constructor declaration may not have a type annotation - const ctor = ensureBindingAliasesInParameterList( - input, - factory.createConstructorDeclaration( - /*modifiers*/ ensureModifiers(input), - updateParamsList(input, input.parameters, ModifierFlags.None), - /*body*/ undefined, - ), + const ctor = factory.createConstructorDeclaration( + /*modifiers*/ ensureModifiers(input), + updateParamsList(input, input.parameters, ModifierFlags.None), + /*body*/ undefined, ); return cleanup(ctor); } @@ -1392,18 +1154,15 @@ export function transformDeclarations(context: TransformationContext) { if (isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } - const sig = ensureBindingAliasesInParameterList( - input, - factory.createMethodDeclaration( - ensureModifiers(input), - /*asteriskToken*/ undefined, - input.name, - input.questionToken, - ensureTypeParams(input, input.typeParameters), - updateParamsList(input, input.parameters), - ensureType(input, input.type), - /*body*/ undefined, - ), + const sig = factory.createMethodDeclaration( + ensureModifiers(input), + /*asteriskToken*/ undefined, + input.name, + input.questionToken, + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters), + ensureType(input, input.type), + /*body*/ undefined, ); return cleanup(sig); } @@ -1412,31 +1171,25 @@ export function transformDeclarations(context: TransformationContext) { return cleanup(/*returnValue*/ undefined); } const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(ensureBindingAliasesInParameterList( + return cleanup(factory.updateGetAccessorDeclaration( input, - factory.updateGetAccessorDeclaration( - input, - ensureModifiers(input), - input.name, - updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)), - ensureType(input, accessorType), - /*body*/ undefined, - ), + ensureModifiers(input), + input.name, + updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)), + ensureType(input, accessorType), + /*body*/ undefined, )); } case SyntaxKind.SetAccessor: { if (isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } - return cleanup(ensureBindingAliasesInParameterList( + return cleanup(factory.updateSetAccessorDeclaration( input, - factory.updateSetAccessorDeclaration( - input, - ensureModifiers(input), - input.name, - updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)), - /*body*/ undefined, - ), + ensureModifiers(input), + input.name, + updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)), + /*body*/ undefined, )); } case SyntaxKind.PropertyDeclaration: @@ -1466,29 +1219,25 @@ export function transformDeclarations(context: TransformationContext) { if (isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } - return cleanup(ensureBindingAliasesInParameterList( + return cleanup(factory.updateMethodSignature( input, - factory.updateMethodSignature( - input, - ensureModifiers(input), - input.name, - input.questionToken, - ensureTypeParams(input, input.typeParameters), - updateParamsList(input, input.parameters), - ensureType(input, input.type), - ), + ensureModifiers(input), + input.name, + input.questionToken, + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters), + ensureType(input, input.type), )); } case SyntaxKind.CallSignature: { - return cleanup(ensureBindingAliasesInParameterList( - input, + return cleanup( factory.updateCallSignature( input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), ), - )); + ); } case SyntaxKind.IndexSignature: { return cleanup(factory.updateIndexSignature( @@ -1529,26 +1278,20 @@ export function transformDeclarations(context: TransformationContext) { return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } case SyntaxKind.FunctionType: { - return cleanup(ensureBindingAliasesInParameterList( + return cleanup(factory.updateFunctionTypeNode( input, - factory.updateFunctionTypeNode( - input, - visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration), - updateParamsList(input, input.parameters), - Debug.checkDefined(visitNode(input.type, visitDeclarationSubtree, isTypeNode)), - ), + visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration), + updateParamsList(input, input.parameters), + Debug.checkDefined(visitNode(input.type, visitDeclarationSubtree, isTypeNode)), )); } case SyntaxKind.ConstructorType: { - return cleanup(ensureBindingAliasesInParameterList( + return cleanup(factory.updateConstructorTypeNode( input, - factory.updateConstructorTypeNode( - input, - ensureModifiers(input), - visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration), - updateParamsList(input, input.parameters), - Debug.checkDefined(visitNode(input.type, visitDeclarationSubtree, isTypeNode)), - ), + ensureModifiers(input), + visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration), + updateParamsList(input, input.parameters), + Debug.checkDefined(visitNode(input.type, visitDeclarationSubtree, isTypeNode)), )); } case SyntaxKind.ImportType: { @@ -1756,18 +1499,15 @@ export function transformDeclarations(context: TransformationContext) { } case SyntaxKind.FunctionDeclaration: { // Generators lose their generator-ness, excepting their return type - const clean = cleanup(ensureBindingAliasesInParameterList( + const clean = cleanup(factory.updateFunctionDeclaration( input, - factory.updateFunctionDeclaration( - input, - ensureModifiers(input), - /*asteriskToken*/ undefined, - input.name, - ensureTypeParams(input, input.typeParameters), - updateParamsList(input, input.parameters), - ensureType(input, input.type), - /*body*/ undefined, - ), + ensureModifiers(input), + /*asteriskToken*/ undefined, + input.name, + ensureTypeParams(input, input.typeParameters), + updateParamsList(input, input.parameters), + ensureType(input, input.type), + /*body*/ undefined, )); if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { const props = resolver.getPropertiesOfContainerFunction(input); diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index e715a2dd815e4..f8849b8cb23f7 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -156,7 +156,6 @@ import { NodeCheckFlags, NodeFlags, nodeIsSynthesized, - nullTransformationContext, NumericLiteral, ObjectLiteralElementLike, ObjectLiteralExpression, @@ -1642,12 +1641,12 @@ export function transformES2015(context: TransformationContext): (x: SourceFile case SyntaxKind.PropertyDeclaration: { const named = node as AccessorDeclaration | MethodDeclaration | PropertyDeclaration; if (isComputedPropertyName(named.name)) { - return factory.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, nullTransformationContext)); + return factory.replacePropertyName(named, visitEachChild(named.name, elideUnusedThisCaptureWorker, /*context*/ undefined)); } return node; } } - return visitEachChild(node, elideUnusedThisCaptureWorker, nullTransformationContext); + return visitEachChild(node, elideUnusedThisCaptureWorker, /*context*/ undefined); } /** @@ -1728,12 +1727,12 @@ export function transformES2015(context: TransformationContext): (x: SourceFile case SyntaxKind.PropertyDeclaration: { const named = node as AccessorDeclaration | MethodDeclaration | PropertyDeclaration; if (isComputedPropertyName(named.name)) { - return factory.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, nullTransformationContext)); + return factory.replacePropertyName(named, visitEachChild(named.name, injectSuperPresenceCheckWorker, /*context*/ undefined)); } return node; } } - return visitEachChild(node, injectSuperPresenceCheckWorker, nullTransformationContext); + return visitEachChild(node, injectSuperPresenceCheckWorker, /*context*/ undefined); } /** diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0376471ced20b..ad795c9ba7965 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5592,7 +5592,6 @@ export type LateVisibilityPaintedStatement = /** @internal */ export interface SymbolVisibilityResult { accessibility: SymbolAccessibility; - bindingElementToMakeVisible?: BindingElement; aliasesToMakeVisible?: LateVisibilityPaintedStatement[]; // aliases that need to have this symbol visible errorSymbolName?: string; // Optional symbol name that results in error errorNode?: Node; // optional node that results in error @@ -5971,6 +5970,7 @@ export const enum InternalSymbolName { Default = "default", // Default export symbol (technically not wholly internal, but included here for usability) This = "this", InstantiationExpression = "__instantiationExpression", // Instantiation expressions + ImportAttributes = "__importAttributes", } /** @@ -6707,8 +6707,9 @@ export interface StringMappingType extends InstantiableType { // Substitution types are created for type parameters or indexed access types that occur in the // true branch of a conditional type. For example, in 'T extends string ? Foo : Bar', the // reference to T in Foo is resolved as a substitution type that substitutes 'string & T' for T. -// Thus, if Foo has a 'string' constraint on its type parameter, T will satisfy it. Substitution -// types disappear upon instantiation (just like type parameters). +// Thus, if Foo has a 'string' constraint on its type parameter, T will satisfy it. +// Substitution type are also created for NoInfer types. Those are represented as substitution +// types where the constraint is type 'unknown' (which is never generated for the case above). export interface SubstitutionType extends InstantiableType { objectFlags: ObjectFlags; baseType: Type; // Target type @@ -10074,6 +10075,7 @@ export interface UserPreferences { readonly organizeImportsNumericCollation?: boolean; readonly organizeImportsAccentCollation?: boolean; readonly organizeImportsCaseFirst?: "upper" | "lower" | false; + readonly organizeImportsTypeOrder?: "first" | "last" | "inline"; readonly excludeLibrarySymbolsInNavTo?: boolean; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 843249e4bba29..e3ef9f744ea11 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -220,6 +220,7 @@ import { idText, IfStatement, ignoredPaths, + ImportAttribute, ImportCall, ImportClause, ImportDeclaration, @@ -282,6 +283,7 @@ import { isJSDoc, isJSDocAugmentsTag, isJSDocFunctionType, + isJSDocImplementsTag, isJSDocLinkLike, isJSDocMemberName, isJSDocNameReference, @@ -2430,7 +2432,6 @@ export const fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; const defaultLibReferenceRegEx = /^(\/\/\/\s*/; -/** @internal */ export function isPartOfTypeNode(node: Node): boolean { if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) { return true; @@ -2452,7 +2453,7 @@ export function isPartOfTypeNode(node: Node): boolean { case SyntaxKind.VoidKeyword: return node.parent.kind !== SyntaxKind.VoidExpression; case SyntaxKind.ExpressionWithTypeArguments: - return isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); + return isPartOfTypeExpressionWithTypeArguments(node); case SyntaxKind.TypeParameter: return node.parent.kind === SyntaxKind.MappedType || node.parent.kind === SyntaxKind.InferType; @@ -2491,7 +2492,7 @@ export function isPartOfTypeNode(node: Node): boolean { } switch (parent.kind) { case SyntaxKind.ExpressionWithTypeArguments: - return isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + return isPartOfTypeExpressionWithTypeArguments(parent); case SyntaxKind.TypeParameter: return node === (parent as TypeParameterDeclaration).constraint; case SyntaxKind.JSDocTemplateTag: @@ -2527,6 +2528,12 @@ export function isPartOfTypeNode(node: Node): boolean { return false; } +function isPartOfTypeExpressionWithTypeArguments(node: Node) { + return isJSDocImplementsTag(node.parent) + || isJSDocAugmentsTag(node.parent) + || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); +} + /** @internal */ export function isChildOfNodeWithKind(node: Node, kind: SyntaxKind): boolean { while (node) { @@ -10649,3 +10656,8 @@ export function replaceFirstStar(s: string, replacement: string): string { // Attempt to defeat this analysis by indirectly calling the method. return stringReplace.call(s, "*", replacement); } + +/** @internal */ +export function getNameFromImportAttribute(node: ImportAttribute) { + return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text); +} diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 688ef16272039..0a1097326f4af 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -32,8 +32,10 @@ import { ClassLikeDeclaration, ClassStaticBlockDeclaration, combinePaths, + CommentRange, compareDiagnostics, CompilerOptions, + concatenate, ConciseBody, ConstructorDeclaration, ConstructorTypeNode, @@ -62,6 +64,7 @@ import { filter, find, flatMap, + forEach, ForInitializer, ForInOrOfStatement, FunctionBody, @@ -81,6 +84,10 @@ import { getJSDocCommentsAndTags, getJSDocRoot, getJSDocTypeParameterDeclarations, + getLeadingCommentRanges, + getLeadingCommentRangesOfNode, + getSourceFileOfNode, + getTrailingCommentRanges, hasAccessorModifier, HasDecorators, hasDecorators, @@ -204,6 +211,7 @@ import { JsxTagNameExpression, KeywordSyntaxKind, LabeledStatement, + last, lastOrUndefined, LeftHandSideExpression, length, @@ -258,9 +266,11 @@ import { setUILocale, SignatureDeclaration, skipOuterExpressions, + skipTrivia, some, sortAndDeduplicate, SortedReadonlyArray, + SourceFile, Statement, StringLiteral, StringLiteralLike, @@ -2376,7 +2386,6 @@ export function isDeclaration(node: Node): node is NamedDeclaration { return isDeclarationKind(node.kind); } -/** @internal */ export function isDeclarationStatement(node: Node): node is DeclarationStatement { return isDeclarationStatementKind(node.kind); } @@ -2606,3 +2615,32 @@ export function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): const type = isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; return (node as ParameterDeclaration).dotDotDotToken !== undefined || !!type && type.kind === SyntaxKind.JSDocVariadicType; } + +function hasInternalAnnotation(range: CommentRange, sourceFile: SourceFile) { + const comment = sourceFile.text.substring(range.pos, range.end); + return comment.includes("@internal"); +} + +export function isInternalDeclaration(node: Node, sourceFile?: SourceFile) { + sourceFile ??= getSourceFileOfNode(node); + const parseTreeNode = getParseTreeNode(node); + if (parseTreeNode && parseTreeNode.kind === SyntaxKind.Parameter) { + const paramIdx = (parseTreeNode.parent as SignatureDeclaration).parameters.indexOf(parseTreeNode as ParameterDeclaration); + const previousSibling = paramIdx > 0 ? (parseTreeNode.parent as SignatureDeclaration).parameters[paramIdx - 1] : undefined; + const text = sourceFile.text; + const commentRanges = previousSibling + ? concatenate( + // to handle + // ... parameters, /** @internal */ + // public param: string + getTrailingCommentRanges(text, skipTrivia(text, previousSibling.end + 1, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true)), + getLeadingCommentRanges(text, node.pos), + ) + : getTrailingCommentRanges(text, skipTrivia(text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true)); + return some(commentRanges) && hasInternalAnnotation(last(commentRanges), sourceFile); + } + const leadingCommentRanges = parseTreeNode && getLeadingCommentRangesOfNode(parseTreeNode, sourceFile); + return !!forEach(leadingCommentRanges, range => { + return hasInternalAnnotation(range, sourceFile!); + }); +} diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index c5e99d170911c..0a4c746c2e7c6 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -90,6 +90,7 @@ import { NodeArray, NodesVisitor, NodeVisitor, + nullTransformationContext, ParameterDeclaration, ScriptTarget, setEmitFlags, @@ -580,9 +581,9 @@ export function visitCommaListElements(elements: NodeArray, visitor: * @param visitor The callback used to visit each child. * @param context A lexical environment context for the visitor. */ -export function visitEachChild(node: T, visitor: Visitor, context: TransformationContext): T; +export function visitEachChild(node: T, visitor: Visitor, context: TransformationContext | undefined): T; /** @internal */ -export function visitEachChild(node: T, visitor: Visitor, context: TransformationContext, nodesVisitor?: NodesVisitor, tokenVisitor?: Visitor, nodeVisitor?: NodeVisitor): T; // eslint-disable-line @typescript-eslint/unified-signatures +export function visitEachChild(node: T, visitor: Visitor, context: TransformationContext | undefined, nodesVisitor?: NodesVisitor, tokenVisitor?: Visitor, nodeVisitor?: NodeVisitor): T; // eslint-disable-line @typescript-eslint/unified-signatures /** * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. * @@ -590,10 +591,10 @@ export function visitEachChild(node: T, visitor: Visitor, contex * @param visitor The callback used to visit each child. * @param context A lexical environment context for the visitor. */ -export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; +export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext | undefined, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; /** @internal */ -export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: NodesVisitor, tokenVisitor?: Visitor, nodeVisitor?: NodeVisitor): T | undefined; -export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes, tokenVisitor?: Visitor, nodeVisitor: NodeVisitor = visitNode): T | undefined { +export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext | undefined, nodesVisitor?: NodesVisitor, tokenVisitor?: Visitor, nodeVisitor?: NodeVisitor): T | undefined; +export function visitEachChild(node: T | undefined, visitor: Visitor, context = nullTransformationContext, nodesVisitor = visitNodes, tokenVisitor?: Visitor, nodeVisitor: NodeVisitor = visitNode): T | undefined { if (node === undefined) { return undefined; } diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index 5763b24c6bde6..7d9d3c6c9f9bb 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -2448,7 +2448,13 @@ export class TestState { const annotations = this.annotateContentWithTooltips( result, "completions", - item => item.optionalReplacementSpan, + item => { + if (item.optionalReplacementSpan) { + const { start, length } = item.optionalReplacementSpan; + return start && length === 0 ? { start, length: 1 } : item.optionalReplacementSpan; + } + return undefined; + }, item => item.entries?.flatMap( entry => @@ -3521,10 +3527,12 @@ export class TestState { actualTextArray.push(text); // Undo changes to perform next fix - const span = change.textChanges[0].span; - const deletedText = originalContent.substr(span.start, change.textChanges[0].span.length); - const insertedText = change.textChanges[0].newText; - this.editScriptAndUpdateMarkers(fileName, span.start, span.start + insertedText.length, deletedText); + for (const textChange of change.textChanges) { + const span = textChange.span; + const deletedText = originalContent.slice(span.start, span.start + textChange.span.length); + const insertedText = textChange.newText; + this.editScriptAndUpdateMarkers(fileName, span.start, span.start + insertedText.length, deletedText); + } } if (expectedTextArray.length !== actualTextArray.length) { this.raiseError(`Expected ${expectedTextArray.length} import fixes, got ${actualTextArray.length}:\n\n${actualTextArray.join("\n\n" + "-".repeat(20) + "\n\n")}`); diff --git a/src/harness/fourslashInterfaceImpl.ts b/src/harness/fourslashInterfaceImpl.ts index 52e028c5070bb..309dc84fb45f4 100644 --- a/src/harness/fourslashInterfaceImpl.ts +++ b/src/harness/fourslashInterfaceImpl.ts @@ -1195,6 +1195,7 @@ export namespace Completion { typeEntry("Lowercase"), typeEntry("Capitalize"), typeEntry("Uncapitalize"), + typeEntry("NoInfer"), interfaceEntry("ThisType"), varEntry("ArrayBuffer"), interfaceEntry("ArrayBufferTypes"), diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts index 298d8310161a3..7b7506d30f5bb 100644 --- a/src/harness/harnessIO.ts +++ b/src/harness/harnessIO.ts @@ -25,7 +25,7 @@ export interface IO { fileExists(fileName: string): boolean; directoryExists(path: string): boolean; deleteFile(fileName: string): void; - enumerateTestFiles(runner: RunnerBase): (string | FileBasedTest)[]; + enumerateTestFiles(runner: RunnerBase): string[]; listFiles(path: string, filter?: RegExp, options?: { recursive?: boolean; }): string[]; log(text: string): void; args(): string[]; @@ -84,55 +84,28 @@ function createNodeIO(): IO { return runner.getTestFiles(); } - function listFiles(path: string, spec: RegExp, options: { recursive?: boolean; } = {}) { + function listFiles(path: string, spec: RegExp | undefined, options: { recursive?: boolean; } = {}) { function filesInFolder(folder: string): string[] { + const { files, directories } = ts.sys.getAccessibleFileSystemEntries!(folder); let paths: string[] = []; - - for (const file of fs.readdirSync(folder)) { + for (const file of files) { const pathToFile = pathModule.join(folder, file); - if (!fs.existsSync(pathToFile)) continue; // ignore invalid symlinks - const stat = fs.statSync(pathToFile); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(pathToFile)); - } - else if (stat.isFile() && (!spec || file.match(spec))) { + if (!spec || file.match(spec)) { paths.push(pathToFile); } } - + if (options.recursive) { + for (const dir of directories) { + const pathToDir = pathModule.join(folder, dir); + paths = paths.concat(filesInFolder(pathToDir)); + } + } return paths; } return filesInFolder(path); } - function getAccessibleFileSystemEntries(dirname: string): ts.FileSystemEntries { - try { - const entries: string[] = fs.readdirSync(dirname || ".").sort(ts.sys.useCaseSensitiveFileNames ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive); - const files: string[] = []; - const directories: string[] = []; - for (const entry of entries) { - if (entry === "." || entry === "..") continue; - const name = vpath.combine(dirname, entry); - try { - const stat = fs.statSync(name); - if (!stat) continue; - if (stat.isFile()) { - files.push(entry); - } - else if (stat.isDirectory()) { - directories.push(entry); - } - } - catch { /*ignore*/ } - } - return { files, directories }; - } - catch (e) { - return { files: [], directories: [] }; - } - } - function createDirectory(path: string) { try { fs.mkdirSync(path); @@ -170,7 +143,7 @@ function createNodeIO(): IO { getWorkspaceRoot: () => workspaceRoot, exit: exitCode => ts.sys.exit(exitCode), readDirectory: (path, extension, exclude, include, depth) => ts.sys.readDirectory(path, extension, exclude, include, depth), - getAccessibleFileSystemEntries, + getAccessibleFileSystemEntries: ts.sys.getAccessibleFileSystemEntries!, tryEnableSourceMapsForHost: () => ts.sys.tryEnableSourceMapsForHost && ts.sys.tryEnableSourceMapsForHost(), getMemoryUsage: () => ts.sys.getMemoryUsage && ts.sys.getMemoryUsage(), getEnvironmentVariable: name => ts.sys.getEnvironmentVariable(name), diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 1877d763e9fea..fbe8f32b299f7 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -1,5 +1,4 @@ import { - FileBasedTest, IO, userSpecifiedRoot, } from "./_namespaces/Harness"; @@ -22,7 +21,7 @@ export function setShardId(id: number) { export abstract class RunnerBase { // contains the tests to run - public tests: (string | FileBasedTest)[] = []; + public tests: string[] = []; /** Add a source file to the runner's list of tests that need to be initialized with initializeTests */ public addTest(fileName: string) { @@ -35,7 +34,7 @@ export abstract class RunnerBase { abstract kind(): TestRunnerKind; - abstract enumerateTestFiles(): (string | FileBasedTest)[]; + abstract enumerateTestFiles(): string[]; getTestFiles(): ReturnType { const all = this.enumerateTestFiles(); diff --git a/src/harness/vfsUtil.ts b/src/harness/vfsUtil.ts index 5d34d0bf15fb5..1d387f0c16c3f 100644 --- a/src/harness/vfsUtil.ts +++ b/src/harness/vfsUtil.ts @@ -656,8 +656,8 @@ export class FileSystem { if (isDirectory(node)) throw createIOError("EISDIR"); if (!isFile(node)) throw createIOError("EBADF"); - const buffer = this._getBuffer(node).slice(); - return encoding ? buffer.toString(encoding) : buffer; + const fileBuffer = this._getBuffer(node, encoding ?? undefined); + return !fileBuffer.encoding ? fileBuffer.data.slice() : fileBuffer.data; } /** @@ -681,8 +681,11 @@ export class FileSystem { if (isDirectory(node)) throw createIOError("EISDIR"); if (!isFile(node)) throw createIOError("EBADF"); - node.buffer = Buffer.isBuffer(data) ? data.slice() : ts.sys.bufferFrom!("" + data, encoding || "utf8") as Buffer; - node.size = node.buffer.byteLength; + node.buffer = Buffer.isBuffer(data) ? + { encoding: undefined, data: data.slice() } : + { encoding: (encoding ?? "utf8") as BufferEncoding, data }; + // Updated the size if it's easy to get, otherwise set to undefined. _getSize will compute the correct size + node.size = !node.buffer.encoding ? node.buffer.data.byteLength : undefined; node.mtimeMs = time; node.ctimeMs = time; } @@ -700,6 +703,7 @@ export class FileSystem { return hasDifferences ? differences : undefined; } + public static defaultEncoding: BufferEncoding | undefined = "utf8"; /** * Generates a `FileSet` patch containing all the entries in `changed` that are not in `base`. */ @@ -800,24 +804,28 @@ export class FileSystem { baseNode.resolver === changedNode.resolver && baseNode.source === changedNode.source ) return false; - const changedBuffer = changed._getBuffer(changedNode); - const baseBuffer = base._getBuffer(baseNode); + const encoding = changedNode.buffer?.encoding ?? baseNode.buffer?.encoding ?? FileSystem.defaultEncoding; + const changedBuffer = changed._getBuffer(changedNode, encoding); + const baseBuffer = base._getBuffer(baseNode, encoding); // no difference if both buffers are the same reference if (changedBuffer === baseBuffer) { if (!options.includeChangedFileWithSameContent || changedNode.mtimeMs === baseNode.mtimeMs) return false; - container[basename] = new SameFileWithModifiedTime(changedBuffer); + container[basename] = new SameFileWithModifiedTime(changedBuffer.data, { encoding: changedBuffer.encoding }); return true; } // no difference if both buffers are identical - if (Buffer.compare(changedBuffer, baseBuffer) === 0) { + if ( + !changedBuffer.encoding && !baseBuffer.encoding && Buffer.compare(changedBuffer.data, baseBuffer.data) === 0 // same buffer content + || changedBuffer.encoding === baseBuffer.encoding && changedBuffer.data === baseBuffer.data // same string content + ) { if (!options.includeChangedFileWithSameContent) return false; - container[basename] = new SameFileContentFile(changedBuffer); + container[basename] = new SameFileContentFile(changedBuffer.data, { encoding: changedBuffer.encoding }); return true; } - container[basename] = new File(changedBuffer); + container[basename] = new File(changedBuffer.data, { encoding: changedBuffer.encoding }); return true; } @@ -838,7 +846,8 @@ export class FileSystem { container[basename] = new Symlink(node.symlink); } else { - container[basename] = new File(changed._getBuffer(node)); + const buffer = changed._getBuffer(node, FileSystem.defaultEncoding); + container[basename] = new File(buffer.data, { encoding: buffer.encoding ?? undefined }); } return true; } @@ -984,14 +993,14 @@ export class FileSystem { } private _getSize(node: FileInode): number { - if (node.buffer) return node.buffer.byteLength; + if (node.buffer) return Buffer.byteLength(node.buffer.data); if (node.size !== undefined) return node.size; if (node.source && node.resolver) return node.size = node.resolver.statSync(node.source).size; if (this._shadowRoot && node.shadowRoot) return node.size = this._shadowRoot._getSize(node.shadowRoot); return 0; } - private _getBuffer(node: FileInode): Buffer { + private _getBuffer(node: FileInode, encoding: BufferEncoding | undefined): FileDataBuffer { if (!node.buffer) { const { source, resolver } = node; if (source && resolver) { @@ -1001,12 +1010,13 @@ export class FileSystem { node.buffer = resolver.readFileSync(source); } else if (this._shadowRoot && node.shadowRoot) { - node.buffer = this._shadowRoot._getBuffer(node.shadowRoot); + node.buffer = this._shadowRoot._getBuffer(node.shadowRoot, encoding); } else { - node.buffer = Buffer.allocUnsafe(0); + node.buffer = { encoding: undefined, data: Buffer.allocUnsafe(0) }; } } + ensureBufferEncoding(node.buffer, encoding); return node.buffer; } @@ -1189,7 +1199,7 @@ export interface Traversal { export interface FileSystemResolver { statSync(path: string): { mode: number; size: number; }; readdirSync(path: string): string[]; - readFileSync(path: string): Buffer; + readFileSync(path: string): FileDataBuffer; } export interface FileSystemResolverHost { @@ -1219,8 +1229,8 @@ export function createResolver(host: FileSystemResolverHost): FileSystemResolver throw new Error("ENOENT: path does not exist"); } }, - readFileSync(path: string): Buffer { - return ts.sys.bufferFrom!(host.readFile(path)!, "utf8") as Buffer; // TODO: GH#18217 + readFileSync(path: string): FileDataBuffer { + return { encoding: "utf8", data: host.readFile(path)! }; }, }; } @@ -1444,6 +1454,17 @@ export class Mount { // a generic POSIX inode type Inode = FileInode | DirectoryInode | SymlinkInode; +type FileDataBuffer = { encoding?: undefined; data: Buffer; } | { encoding: BufferEncoding; data: string; }; + +function ensureBufferEncoding(fileBuffer: FileDataBuffer, encoding: BufferEncoding | undefined) { + if (fileBuffer.encoding === encoding) return; + + const buffer = !fileBuffer.encoding ? fileBuffer.data : ts.sys.bufferFrom!(fileBuffer.data, fileBuffer.encoding); + + fileBuffer.encoding = encoding; + fileBuffer.data = !encoding ? buffer as Buffer : buffer.toString(encoding); +} + interface FileInode { dev: number; // device id ino: number; // inode id @@ -1454,7 +1475,7 @@ interface FileInode { birthtimeMs: number; // creation time nlink: number; // number of hard links size?: number; - buffer?: Buffer; + buffer?: FileDataBuffer; source?: string; resolver?: FileSystemResolver; shadowRoot?: FileInode; diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index f3df23047022d..1177ed2b51395 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1648,6 +1648,11 @@ type Capitalize = intrinsic; */ type Uncapitalize = intrinsic; +/** + * Marker for non-inference type position + */ +type NoInfer = intrinsic; + /** * Marker for contextual 'this' type */ diff --git a/src/lib/esnext.collection.d.ts b/src/lib/esnext.collection.d.ts new file mode 100644 index 0000000000000..7a799f3c494e7 --- /dev/null +++ b/src/lib/esnext.collection.d.ts @@ -0,0 +1,11 @@ +interface MapConstructor { + /** + * Groups members of an iterable according to the return value of the passed callback. + * @param items An iterable. + * @param keySelector A callback which will be invoked for each item in items. + */ + groupBy( + items: Iterable, + keySelector: (item: T, index: number) => K, + ): Map; +} diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 0fd9d10076eea..56d97e566a301 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -3,3 +3,5 @@ /// /// /// +/// +/// diff --git a/src/lib/esnext.object.d.ts b/src/lib/esnext.object.d.ts new file mode 100644 index 0000000000000..0486ac078139c --- /dev/null +++ b/src/lib/esnext.object.d.ts @@ -0,0 +1,11 @@ +interface ObjectConstructor { + /** + * Groups members of an iterable according to the return value of the passed callback. + * @param items An iterable. + * @param keySelector A callback which will be invoked for each item in items. + */ + groupBy( + items: Iterable, + keySelector: (item: T, index: number) => K, + ): Partial>; +} diff --git a/src/lib/libs.json b/src/lib/libs.json index cde5256e8e573..3258386a2c53e 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -74,6 +74,8 @@ "esnext.intl", "esnext.disposable", "esnext.promise", + "esnext.object", + "esnext.collection", "decorators", "decorators.legacy", // Default libraries diff --git a/src/server/protocol.ts b/src/server/protocol.ts index ae6c5bc055143..e0964cea6d9d6 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -3643,6 +3643,13 @@ export interface UserPreferences { * Default: `false` */ readonly organizeImportsCaseFirst?: "upper" | "lower" | false; + /** + * Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is + * type-only. + * + * Default: `last` + */ + readonly organizeImportsTypeOrder?: "last" | "first" | "inline"; /** * Indicates whether {@link ReferencesResponseItem.lineText} is supported. diff --git a/src/services/codefixes/annotateWithTypeFromJSDoc.ts b/src/services/codefixes/annotateWithTypeFromJSDoc.ts index f989025b5cc4c..a73a19abffe60 100644 --- a/src/services/codefixes/annotateWithTypeFromJSDoc.ts +++ b/src/services/codefixes/annotateWithTypeFromJSDoc.ts @@ -27,7 +27,6 @@ import { last, map, Node, - nullTransformationContext, ParameterDeclaration, PropertyDeclaration, PropertySignature, @@ -144,7 +143,7 @@ function transformJSDocType(node: Node): Node { case SyntaxKind.JSDocTypeLiteral: return transformJSDocTypeLiteral(node as JSDocTypeLiteral); default: - const visited = visitEachChild(node, transformJSDocType, nullTransformationContext); + const visited = visitEachChild(node, transformJSDocType, /*context*/ undefined); setEmitFlags(visited, EmitFlags.SingleLine); return visited; } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 804e87040f48b..5e6dd79755636 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -70,7 +70,6 @@ import { NodeArray, NodeBuilderFlags, NodeFlags, - nullTransformationContext, ObjectFlags, ObjectLiteralExpression, ObjectType, @@ -913,7 +912,7 @@ export function tryGetAutoImportableReferenceFromTypeNode(importTypeNode: TypeNo const typeArguments = visitNodes(node.typeArguments, visit, isTypeNode); return factory.createTypeReferenceNode(qualifier, typeArguments); } - return visitEachChild(node, visit, nullTransformationContext); + return visitEachChild(node, visit, /*context*/ undefined); } } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 97c5bca540b54..22cd9693ab98f 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -53,6 +53,7 @@ import { getSourceFileOfNode, getSymbolId, getTokenAtPosition, + getTokenPosOfNode, getTypeKeywordOfTypeOnlyImport, getUniqueSymbolId, hostGetCanonicalFileName, @@ -1406,14 +1407,14 @@ function promoteFromTypeOnly( if (aliasDeclaration.parent.elements.length > 1 && sortKind) { const newSpecifier = factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name); const comparer = OrganizeImports.getOrganizeImportsComparer(preferences, sortKind === SortKind.CaseInsensitive); - const insertionIndex = OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer); - if (aliasDeclaration.parent.elements.indexOf(aliasDeclaration) !== insertionIndex) { + const insertionIndex = OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer, preferences); + if (insertionIndex !== aliasDeclaration.parent.elements.indexOf(aliasDeclaration)) { changes.delete(sourceFile, aliasDeclaration); changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex); return aliasDeclaration; } } - changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken()!); + changes.deleteRange(sourceFile, { pos: getTokenPosOfNode(aliasDeclaration.getFirstToken()!), end: getTokenPosOfNode(aliasDeclaration.propertyName ?? aliasDeclaration.name) }); return aliasDeclaration; } else { @@ -1538,7 +1539,7 @@ function doAddExistingFix( // type-only, there's no need to ask for the insertion index - it's 0. const insertionIndex = promoteFromTypeOnly && !spec.isTypeOnly ? 0 - : OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer); + : OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer, preferences); changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings as NamedImports, insertionIndex); } } diff --git a/src/services/completions.ts b/src/services/completions.ts index 155d048562b78..234a4072c76a5 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -95,6 +95,7 @@ import { getLineStartPositionForPosition, getLocalSymbolForExportDefault, getModifiers, + getNameFromImportAttribute, getNameOfDeclaration, getNameTable, getNewLineCharacter, @@ -169,6 +170,7 @@ import { isIdentifier, isIdentifierText, isImportableFile, + isImportAttributes, isImportDeclaration, isImportEqualsDeclaration, isImportKeyword, @@ -3768,6 +3770,7 @@ function getCompletionData( || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() + || tryGetImportAttributesCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() @@ -4455,6 +4458,21 @@ function getCompletionData( return GlobalsSearch.Success; } + /** + * import { x } from "foo" with { | } + */ + function tryGetImportAttributesCompletionSymbols(): GlobalsSearch { + if (contextToken === undefined) return GlobalsSearch.Continue; + + const importAttributes = contextToken.kind === SyntaxKind.OpenBraceToken || contextToken.kind === SyntaxKind.CommaToken ? tryCast(contextToken.parent, isImportAttributes) : + contextToken.kind === SyntaxKind.ColonToken ? tryCast(contextToken.parent.parent, isImportAttributes) : undefined; + if (importAttributes === undefined) return GlobalsSearch.Continue; + + const existing = new Set(importAttributes.elements.map(getNameFromImportAttribute)); + symbols = filter(typeChecker.getTypeAtLocation(importAttributes).getApparentProperties(), attr => !existing.has(attr.escapedName)); + return GlobalsSearch.Success; + } + /** * Adds local declarations for completions in named exports: * diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 06aea522ce9be..826dfe9eb591b 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -234,6 +234,7 @@ import { StringLiteralLike, stripQuotes, SuperContainer, + SwitchStatement, Symbol, SymbolDisplay, SymbolDisplayPart, @@ -406,7 +407,7 @@ function getContextNodeForNodeEntry(node: Node): ContextNode | undefined { } /** @internal */ -export function getContextNode(node: NamedDeclaration | BinaryExpression | ForInOrOfStatement | undefined): ContextNode | undefined { +export function getContextNode(node: NamedDeclaration | BinaryExpression | ForInOrOfStatement | SwitchStatement | undefined): ContextNode | undefined { if (!node) return undefined; switch (node.kind) { case SyntaxKind.VariableDeclaration: @@ -451,14 +452,18 @@ export function getContextNode(node: NamedDeclaration | BinaryExpression | ForIn findAncestor(node.parent, node => isBinaryExpression(node) || isForInOrOfStatement(node)) as BinaryExpression | ForInOrOfStatement, ) : node; - + case SyntaxKind.SwitchStatement: + return { + start: find(node.getChildren(node.getSourceFile()), node => node.kind === SyntaxKind.SwitchKeyword)!, + end: (node as SwitchStatement).caseBlock, + }; default: return node; } } /** @internal */ -export function toContextSpan(textSpan: TextSpan, sourceFile: SourceFile, context?: ContextNode): { contextSpan: TextSpan; } | undefined { +export function toContextSpan(textSpan: TextSpan, sourceFile: SourceFile, context: ContextNode | undefined): { contextSpan: TextSpan; } | undefined { if (!context) return undefined; const contextSpan = isContextWithStartAndEndNode(context) ? getTextSpan(context.start, sourceFile, context.end) : @@ -874,6 +879,9 @@ function getTextSpan(node: Node, sourceFile: SourceFile, endNode?: Node): TextSp start += 1; end -= 1; } + if (endNode?.kind === SyntaxKind.CaseBlock) { + end = endNode.getFullStart(); + } return createTextSpanFromBounds(start, end); } diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index c603c6c7bab3d..79afa66a4d3a6 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -53,6 +53,7 @@ import { isClassStaticBlockDeclaration, isConstructorDeclaration, isDeclarationFileName, + isDefaultClause, isExternalModuleNameRelative, isFunctionLike, isFunctionLikeDeclaration, @@ -69,6 +70,7 @@ import { isPropertyName, isRightSideOfPropertyAccess, isStaticModifier, + isSwitchStatement, isTypeAliasDeclaration, isTypeReferenceNode, isVariableDeclaration, @@ -91,6 +93,7 @@ import { skipTrivia, some, SourceFile, + SwitchStatement, Symbol, SymbolDisplay, SymbolFlags, @@ -105,6 +108,9 @@ import { TypeReference, unescapeLeadingUnderscores, } from "./_namespaces/ts"; +import { + isContextWithStartAndEndNode, +} from "./_namespaces/ts.FindAllReferences"; /** @internal */ export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number, searchOtherFilesOnly?: boolean, stopAtAlias?: boolean): readonly DefinitionInfo[] | undefined { @@ -133,9 +139,26 @@ export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile return label ? [createDefinitionInfoFromName(typeChecker, label, ScriptElementKind.label, node.text, /*containerName*/ undefined!)] : undefined; // TODO: GH#18217 } - if (node.kind === SyntaxKind.ReturnKeyword) { - const functionDeclaration = findAncestor(node.parent, n => isClassStaticBlockDeclaration(n) ? "quit" : isFunctionLikeDeclaration(n)) as FunctionLikeDeclaration | undefined; - return functionDeclaration ? [createDefinitionFromSignatureDeclaration(typeChecker, functionDeclaration)] : undefined; + switch (node.kind) { + case SyntaxKind.ReturnKeyword: + const functionDeclaration = findAncestor(node.parent, n => + isClassStaticBlockDeclaration(n) + ? "quit" + : isFunctionLikeDeclaration(n)) as FunctionLikeDeclaration | undefined; + return functionDeclaration + ? [createDefinitionFromSignatureDeclaration(typeChecker, functionDeclaration)] + : undefined; + case SyntaxKind.DefaultKeyword: + if (!isDefaultClause(node.parent)) { + break; + } + // falls through + case SyntaxKind.CaseKeyword: + const switchStatement = findAncestor(node.parent, isSwitchStatement); + if (switchStatement) { + return [createDefinitionInfoFromSwitch(switchStatement, sourceFile)]; + } + break; } if (node.kind === SyntaxKind.AwaitKeyword) { @@ -634,6 +657,24 @@ function createDefinitionInfoFromName(checker: TypeChecker, declaration: Declara }; } +function createDefinitionInfoFromSwitch(statement: SwitchStatement, sourceFile: SourceFile): DefinitionInfo { + const keyword = FindAllReferences.getContextNode(statement)!; + const textSpan = createTextSpanFromNode(isContextWithStartAndEndNode(keyword) ? keyword.start : keyword, sourceFile); + return { + fileName: sourceFile.fileName, + textSpan, + kind: ScriptElementKind.keyword, + name: "switch", + containerKind: undefined!, + containerName: "", + ...FindAllReferences.toContextSpan(textSpan, sourceFile, keyword), + isLocal: true, + isAmbient: false, + unverified: false, + failedAliasResolution: undefined, + }; +} + function isDefinitionVisible(checker: TypeChecker, declaration: Declaration): boolean { if (checker.isDeclarationVisible(declaration)) return true; if (!declaration.parent) return false; diff --git a/src/services/organizeImports.ts b/src/services/organizeImports.ts index 777541679b7da..b9c2f7e89096f 100644 --- a/src/services/organizeImports.ts +++ b/src/services/organizeImports.ts @@ -23,8 +23,10 @@ import { flatMap, formatting, getNewLineOrDefaultFromHost, + getStringComparer, getUILocale, group, + groupBy, Identifier, identity, ImportClause, @@ -94,7 +96,7 @@ export function organizeImports( const processImportsOfSameModuleSpecifier = (importGroup: readonly ImportDeclaration[]) => { if (shouldRemove) importGroup = removeUnusedImports(importGroup, sourceFile, program); - if (shouldCombine) importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile); + if (shouldCombine) importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile, preferences); if (shouldSort) importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, comparer)); return importGroup; }; @@ -104,7 +106,7 @@ export function organizeImports( // Exports are always used if (mode !== OrganizeImportsMode.RemoveUnused) { // All of the old ExportDeclarations in the file, in syntactic order. - getTopLevelExportGroups(sourceFile).forEach(exportGroupDecl => organizeImportsWorker(exportGroupDecl, group => coalesceExportsWorker(group, comparer))); + getTopLevelExportGroups(sourceFile).forEach(exportGroupDecl => organizeImportsWorker(exportGroupDecl, group => coalesceExportsWorker(group, comparer, preferences))); } for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) { @@ -116,7 +118,7 @@ export function organizeImports( // Exports are always used if (mode !== OrganizeImportsMode.RemoveUnused) { const ambientModuleExportDecls = ambientModule.body.statements.filter(isExportDeclaration); - organizeImportsWorker(ambientModuleExportDecls, group => coalesceExportsWorker(group, comparer)); + organizeImportsWorker(ambientModuleExportDecls, group => coalesceExportsWorker(group, comparer, preferences)); } } @@ -310,12 +312,12 @@ function getExternalModuleName(specifier: Expression | undefined) { * @deprecated Only used for testing * @internal */ -export function coalesceImports(importGroup: readonly ImportDeclaration[], ignoreCase: boolean, sourceFile?: SourceFile): readonly ImportDeclaration[] { +export function coalesceImports(importGroup: readonly ImportDeclaration[], ignoreCase: boolean, sourceFile?: SourceFile, preferences?: UserPreferences): readonly ImportDeclaration[] { const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase); - return coalesceImportsWorker(importGroup, comparer, sourceFile); + return coalesceImportsWorker(importGroup, comparer, sourceFile, preferences); } -function coalesceImportsWorker(importGroup: readonly ImportDeclaration[], comparer: Comparer, sourceFile?: SourceFile): readonly ImportDeclaration[] { +function coalesceImportsWorker(importGroup: readonly ImportDeclaration[], comparer: Comparer, sourceFile?: SourceFile, preferences?: UserPreferences): readonly ImportDeclaration[] { if (importGroup.length === 0) { return importGroup; } @@ -374,7 +376,7 @@ function coalesceImportsWorker(importGroup: readonly ImportDeclaration[], compar newImportSpecifiers.push(...getNewImportSpecifiers(namedImports)); const sortedImportSpecifiers = factory.createNodeArray( - sortSpecifiers(newImportSpecifiers, comparer), + sortSpecifiers(newImportSpecifiers, comparer, preferences), firstNamedImport?.importClause.namedBindings.elements.hasTrailingComma, ); @@ -491,18 +493,17 @@ function getCategorizedImports(importGroup: readonly ImportDeclaration[]) { * @deprecated Only used for testing * @internal */ -export function coalesceExports(exportGroup: readonly ExportDeclaration[], ignoreCase: boolean) { +export function coalesceExports(exportGroup: readonly ExportDeclaration[], ignoreCase: boolean, preferences?: UserPreferences) { const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase); - return coalesceExportsWorker(exportGroup, comparer); + return coalesceExportsWorker(exportGroup, comparer, preferences); } -function coalesceExportsWorker(exportGroup: readonly ExportDeclaration[], comparer: Comparer) { +function coalesceExportsWorker(exportGroup: readonly ExportDeclaration[], comparer: Comparer, preferences?: UserPreferences) { if (exportGroup.length === 0) { return exportGroup; } const { exportWithoutClause, namedExports, typeOnlyExports } = getCategorizedExports(exportGroup); - const coalescedExports: ExportDeclaration[] = []; if (exportWithoutClause) { @@ -516,7 +517,7 @@ function coalesceExportsWorker(exportGroup: readonly ExportDeclaration[], compar const newExportSpecifiers: ExportSpecifier[] = []; newExportSpecifiers.push(...flatMap(exportGroup, i => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray)); - const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer); + const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer, preferences); const exportDecl = exportGroup[0]; coalescedExports.push( @@ -583,13 +584,20 @@ function updateImportDeclarationAndClause( ); } -function sortSpecifiers(specifiers: readonly T[], comparer: Comparer) { - return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer)); +function sortSpecifiers(specifiers: readonly T[], comparer: Comparer, preferences?: UserPreferences): readonly T[] { + return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences)); } /** @internal */ -export function compareImportOrExportSpecifiers(s1: T, s2: T, comparer: Comparer): Comparison { - return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text); +export function compareImportOrExportSpecifiers(s1: T, s2: T, comparer: Comparer, preferences?: UserPreferences): Comparison { + switch (preferences?.organizeImportsTypeOrder) { + case "first": + return compareBooleans(s2.isTypeOnly, s1.isTypeOnly) || comparer(s1.name.text, s2.name.text); + case "inline": + return comparer(s1.name.text, s2.name.text); + default: + return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text); + } } /** @@ -721,11 +729,51 @@ class ImportSpecifierSortingCache implements MemoizeCache<[readonly ImportSpecif /** @internal */ export const detectImportSpecifierSorting = memoizeCached((specifiers: readonly ImportSpecifier[], preferences: UserPreferences): SortKind => { - if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly))) { - return SortKind.None; + // If types are not sorted as specified, then imports are assumed to be unsorted. + // If there is no type sorting specification, we default to "last" and move on to case sensitivity detection. + switch (preferences.organizeImportsTypeOrder) { + case "first": + if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s2.isTypeOnly, s1.isTypeOnly))) return SortKind.None; + break; + case "inline": + if ( + !arrayIsSorted(specifiers, (s1, s2) => { + const comparer = getStringComparer(/*ignoreCase*/ true); + return comparer(s1.name.text, s2.name.text); + }) + ) { + return SortKind.None; + } + break; + default: + if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly))) return SortKind.None; + break; } + const collateCaseSensitive = getOrganizeImportsComparer(preferences, /*ignoreCase*/ false); const collateCaseInsensitive = getOrganizeImportsComparer(preferences, /*ignoreCase*/ true); + + if (preferences.organizeImportsTypeOrder !== "inline") { + const { type: regularImports, regular: typeImports } = groupBy(specifiers, s => s.isTypeOnly ? "type" : "regular"); + const regularCaseSensitivity = regularImports?.length + ? detectSortCaseSensitivity(regularImports, specifier => specifier.name.text, collateCaseSensitive, collateCaseInsensitive) + : undefined; + const typeCaseSensitivity = typeImports?.length + ? detectSortCaseSensitivity(typeImports, specifier => specifier.name.text ?? "", collateCaseSensitive, collateCaseInsensitive) + : undefined; + if (regularCaseSensitivity === undefined) { + return typeCaseSensitivity ?? SortKind.None; + } + if (typeCaseSensitivity === undefined) { + return regularCaseSensitivity; + } + if (regularCaseSensitivity === SortKind.None || typeCaseSensitivity === SortKind.None) { + return SortKind.None; + } + return typeCaseSensitivity & regularCaseSensitivity; + } + + // else inline return detectSortCaseSensitivity(specifiers, specifier => specifier.name.text, collateCaseSensitive, collateCaseInsensitive); }, new ImportSpecifierSortingCache()); @@ -736,8 +784,8 @@ export function getImportDeclarationInsertionIndex(sortedImports: readonly AnyIm } /** @internal */ -export function getImportSpecifierInsertionIndex(sortedImports: readonly ImportSpecifier[], newImport: ImportSpecifier, comparer: Comparer) { - const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer)); +export function getImportSpecifierInsertionIndex(sortedImports: readonly ImportSpecifier[], newImport: ImportSpecifier, comparer: Comparer, preferences: UserPreferences) { + const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences)); return index < 0 ? ~index : index; } diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index f25098e2c060a..e55e4e37f7af5 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -120,7 +120,6 @@ import { Node, NodeBuilderFlags, NodeFlags, - nullTransformationContext, ObjectLiteralElementLike, ParameterDeclaration, positionIsSynthesized, @@ -1648,7 +1647,7 @@ function transformFunctionBody(body: Node, exposedVariableDeclarations: readonly const oldIgnoreReturns = ignoreReturns; ignoreReturns = ignoreReturns || isFunctionLikeDeclaration(node) || isClassLike(node); const substitution = substitutions.get(getNodeId(node).toString()); - const result = substitution ? getSynthesizedDeepClone(substitution) : visitEachChild(node, visitor, nullTransformationContext); + const result = substitution ? getSynthesizedDeepClone(substitution) : visitEachChild(node, visitor, /*context*/ undefined); ignoreReturns = oldIgnoreReturns; return result; } @@ -1662,7 +1661,7 @@ function transformConstantInitializer(initializer: Expression, substitutions: Re function visitor(node: Node): VisitResult { const substitution = substitutions.get(getNodeId(node).toString()); - return substitution ? getSynthesizedDeepClone(substitution) : visitEachChild(node, visitor, nullTransformationContext); + return substitution ? getSynthesizedDeepClone(substitution) : visitEachChild(node, visitor, /*context*/ undefined); } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index b48367739786d..5005e4e050a32 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -294,7 +294,6 @@ import { normalizePath, NoSubstitutionTemplateLiteral, notImplemented, - nullTransformationContext, NumericLiteral, or, OrganizeImports, @@ -3175,7 +3174,7 @@ function getSynthesizedDeepCloneWorker(node: T, replaceNode?: (n const nodesClone: (ns: NodeArray | undefined) => NodeArray | undefined = replaceNode ? ns => ns && getSynthesizedDeepClonesWithReplacements(ns, /*includeTrivia*/ true, replaceNode) : ns => ns && getSynthesizedDeepClones(ns); - const visited = visitEachChild(node, nodeClone, nullTransformationContext, nodesClone, nodeClone); + const visited = visitEachChild(node, nodeClone, /*context*/ undefined, nodesClone, nodeClone); if (visited === node) { // This only happens for leaf nodes - internal nodes always see their children change. diff --git a/src/testRunner/compilerRunner.ts b/src/testRunner/compilerRunner.ts index b3c86f6390ff8..b5d08ca8f2e03 100644 --- a/src/testRunner/compilerRunner.ts +++ b/src/testRunner/compilerRunner.ts @@ -51,9 +51,10 @@ export class CompilerBaselineRunner extends RunnerBase { return this.testSuiteName; } + private testFiles: string[] | undefined; public enumerateTestFiles() { // see also: `enumerateTestFiles` in tests/webTestServer.ts - return this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }).map(CompilerTest.getConfigurations); + return this.testFiles ??= this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }); } public initializeTests() { @@ -64,9 +65,8 @@ export class CompilerBaselineRunner extends RunnerBase { // this will set up a series of describe/it blocks to run between the setup and cleanup phases const files = this.tests.length > 0 ? this.tests : IO.enumerateTestFiles(this); - files.forEach(test => { - const file = typeof test === "string" ? test : test.file; - this.checkTestCodeOutput(vpath.normalizeSeparators(file), typeof test === "string" ? CompilerTest.getConfigurations(test) : test); + files.forEach(file => { + this.checkTestCodeOutput(vpath.normalizeSeparators(file), CompilerTest.getConfigurations(file)); }); }); } diff --git a/src/testRunner/fourslashRunner.ts b/src/testRunner/fourslashRunner.ts index 689cdcceca9f4..6fd61eb0e3b08 100644 --- a/src/testRunner/fourslashRunner.ts +++ b/src/testRunner/fourslashRunner.ts @@ -41,8 +41,7 @@ export class FourSlashRunner extends RunnerBase { } describe(this.testSuiteName + " tests", () => { - this.tests.forEach(test => { - const file = typeof test === "string" ? test : test.file; + this.tests.forEach(file => { describe(file, () => { let fn = ts.normalizeSlashes(file); const justName = fn.replace(/^.*[\\/]/, ""); diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 126e06cff4e4a..ca8ffb563d355 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -217,8 +217,7 @@ export function start() { console.log("Discovering runner-based tests..."); const discoverStart = +(new Date()); for (const runner of runners) { - for (const test of runner.getTestFiles()) { - const file = typeof test === "string" ? test : test.file; + for (const file of runner.getTestFiles()) { let size: number; if (!perfData) { try { diff --git a/src/testRunner/projectsRunner.ts b/src/testRunner/projectsRunner.ts index dd2a2f40f6ead..bedb3343e7c50 100644 --- a/src/testRunner/projectsRunner.ts +++ b/src/testRunner/projectsRunner.ts @@ -54,7 +54,7 @@ export class ProjectRunner extends Harness.RunnerBase { describe("projects tests", () => { const tests = this.tests.length === 0 ? this.enumerateTestFiles() : this.tests; for (const test of tests) { - this.runProjectTestCase(typeof test === "string" ? test : test.file); + this.runProjectTestCase(test); } }); } @@ -202,15 +202,36 @@ class ProjectTestCase { throw assert(false, "Testcase: " + testCaseFileName + " does not contain valid json format: " + e.message); } - const fs = vfs.createFromFileSystem(Harness.IO, /*ignoreCase*/ false); - fs.mountSync(vpath.resolve(Harness.IO.getWorkspaceRoot(), "tests"), vpath.combine(vfs.srcFolder, "tests"), vfs.createResolver(Harness.IO)); - fs.mkdirpSync(vpath.combine(vfs.srcFolder, testCase.projectRoot)); - fs.chdir(vpath.combine(vfs.srcFolder, testCase.projectRoot)); - fs.makeReadonly(); - + function makeFileSystem() { + const fs = vfs.createFromFileSystem(Harness.IO, /*ignoreCase*/ false); + fs.mountSync(vpath.resolve(Harness.IO.getWorkspaceRoot(), "tests"), vpath.combine(vfs.srcFolder, "tests"), vfs.createResolver(Harness.IO)); + fs.mkdirpSync(vpath.combine(vfs.srcFolder, testCase.projectRoot)); + fs.chdir(vpath.combine(vfs.srcFolder, testCase.projectRoot)); + fs.makeReadonly(); + return fs; + } + let fs: vfs.FileSystem | undefined; return [ - { name: `@module: commonjs`, payload: { testCase, moduleKind: ts.ModuleKind.CommonJS, vfs: fs } }, - { name: `@module: amd`, payload: { testCase, moduleKind: ts.ModuleKind.AMD, vfs: fs } }, + { + name: `@module: commonjs`, + payload: { + testCase, + moduleKind: ts.ModuleKind.CommonJS, + get vfs() { + return fs ??= makeFileSystem(); + }, + }, + }, + { + name: `@module: amd`, + payload: { + testCase, + moduleKind: ts.ModuleKind.AMD, + get vfs() { + return fs ??= makeFileSystem(); + }, + }, + }, ]; } diff --git a/src/testRunner/runner.ts b/src/testRunner/runner.ts index d8b7bbed8a501..ecf720996e43e 100644 --- a/src/testRunner/runner.ts +++ b/src/testRunner/runner.ts @@ -27,8 +27,7 @@ function runTests(runners: RunnerBase[]) { const dupes: [string, string][] = []; for (const runner of runners) { if (runner instanceof CompilerBaselineRunner || runner instanceof FourSlashRunner) { - for (const sf of runner.enumerateTestFiles()) { - const full = typeof sf === "string" ? sf : sf.file; + for (const full of runner.enumerateTestFiles()) { const base = vpath.basename(full).toLowerCase(); // allow existing dupes in fourslash/shims and fourslash/server if (seen.has(base) && !/fourslash\/(shim|server)/.test(full)) { @@ -191,7 +190,6 @@ function handleTestConfig() { case "fourslash-generated": runners.push(new GeneratedFourslashRunner(FourSlash.FourSlashTestType.Native)); break; - break; } } } diff --git a/src/testRunner/unittests/services/organizeImports.ts b/src/testRunner/unittests/services/organizeImports.ts index be6809a0ade23..e2970ef0d84a1 100644 --- a/src/testRunner/unittests/services/organizeImports.ts +++ b/src/testRunner/unittests/services/organizeImports.ts @@ -239,10 +239,10 @@ describe("unittests:: services:: organizeImports", () => { assertListEqual(actualCoalescedExports, expectedCoalescedExports); }); - it("Sort specifiers - type-only", () => { + it("Sort specifiers - type-only-inline", () => { const sortedImports = parseImports(`import { type z, y, type x, c, type b, a } from "lib";`); - const actualCoalescedImports = ts.OrganizeImports.coalesceImports(sortedImports, /*ignoreCase*/ true); - const expectedCoalescedImports = parseImports(`import { a, c, y, type b, type x, type z } from "lib";`); + const actualCoalescedImports = ts.OrganizeImports.coalesceImports(sortedImports, /*ignoreCase*/ true, ts.getSourceFileOfNode(sortedImports[0]), { organizeImportsTypeOrder: "inline" }); + const expectedCoalescedImports = parseImports(`import { a, type b, c, type x, y, type z } from "lib";`); assertListEqual(actualCoalescedImports, expectedCoalescedImports); }); diff --git a/tests/baselines/reference/allowJsCrossMonorepoPackage.symbols b/tests/baselines/reference/allowJsCrossMonorepoPackage.symbols new file mode 100644 index 0000000000000..dbdc37a135b01 --- /dev/null +++ b/tests/baselines/reference/allowJsCrossMonorepoPackage.symbols @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/allowJsCrossMonorepoPackage.ts] //// + +=== /packages/main/index.ts === +import { x } from "shared"; +>x : Symbol(x, Decl(index.ts, 0, 8)) + +=== /node_modules/pkg/index.d.ts === +export declare function pkg(): "pkg"; +>pkg : Symbol(pkg, Decl(index.d.ts, 0, 0)) + +=== /packages/shared/utils.js === +export { pkg } from "pkg"; +>pkg : Symbol(pkg, Decl(utils.js, 0, 8)) + +=== /packages/shared/index.js === +import { pkg } from "./utils.js"; +>pkg : Symbol(pkg, Decl(index.js, 0, 8)) + +export const x = pkg(); +>x : Symbol(x, Decl(index.js, 1, 12)) +>pkg : Symbol(pkg, Decl(index.js, 0, 8)) + diff --git a/tests/baselines/reference/allowJsCrossMonorepoPackage.trace.json b/tests/baselines/reference/allowJsCrossMonorepoPackage.trace.json new file mode 100644 index 0000000000000..17b86da7c4b24 --- /dev/null +++ b/tests/baselines/reference/allowJsCrossMonorepoPackage.trace.json @@ -0,0 +1,159 @@ +[ + "======== Resolving module 'shared' from '/packages/main/index.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Found 'package.json' at '/packages/main/package.json'.", + "Loading module 'shared' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/packages/main/node_modules/shared/package.json'.", + "Using 'exports' subpath '.' with target './index.js'.", + "File name '/packages/main/node_modules/shared/index.js' has a '.js' extension - stripping it.", + "File '/packages/main/node_modules/shared/index.ts' does not exist.", + "File '/packages/main/node_modules/shared/index.tsx' does not exist.", + "File '/packages/main/node_modules/shared/index.d.ts' does not exist.", + "Directory '/packages/main/node_modules/@types' does not exist, skipping all lookups in it.", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "File '/node_modules/shared.ts' does not exist.", + "File '/node_modules/shared.tsx' does not exist.", + "File '/node_modules/shared.d.ts' does not exist.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", + "File '/packages/main/node_modules/shared/package.json' exists according to earlier cached lookups.", + "Using 'exports' subpath '.' with target './index.js'.", + "File name '/packages/main/node_modules/shared/index.js' has a '.js' extension - stripping it.", + "File '/packages/main/node_modules/shared/index.js' exists - use it as a name resolution result.", + "Resolution of non-relative name failed; trying with modern Node resolution features disabled to see if npm library needs configuration update.", + "File '/packages/main/package.json' exists according to earlier cached lookups.", + "Loading module 'shared' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "File '/packages/main/node_modules/shared/package.json' exists according to earlier cached lookups.", + "File '/packages/main/node_modules/shared.ts' does not exist.", + "File '/packages/main/node_modules/shared.tsx' does not exist.", + "File '/packages/main/node_modules/shared.d.ts' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "File '/packages/main/node_modules/shared/index.ts' does not exist.", + "File '/packages/main/node_modules/shared/index.tsx' does not exist.", + "File '/packages/main/node_modules/shared/index.d.ts' does not exist.", + "Directory '/packages/main/node_modules/@types' does not exist, skipping all lookups in it.", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "File '/node_modules/shared.ts' does not exist.", + "File '/node_modules/shared.tsx' does not exist.", + "File '/node_modules/shared.d.ts' does not exist.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Resolving real path for '/packages/main/node_modules/shared/index.js', result '/packages/shared/index.js'.", + "======== Module name 'shared' was successfully resolved to '/packages/shared/index.js' with Package ID 'shared/index.js@1.0.0'. ========", + "======== Resolving module './utils.js' from '/packages/shared/index.js'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/packages/shared/utils.js', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File name '/packages/shared/utils.js' has a '.js' extension - stripping it.", + "File '/packages/shared/utils.ts' does not exist.", + "File '/packages/shared/utils.tsx' does not exist.", + "File '/packages/shared/utils.d.ts' does not exist.", + "File '/packages/shared/utils.js' exists - use it as a name resolution result.", + "======== Module name './utils.js' was successfully resolved to '/packages/shared/utils.js'. ========", + "======== Resolving module 'pkg' from '/packages/shared/utils.js'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Found 'package.json' at '/packages/shared/package.json'.", + "Loading module 'pkg' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/packages/shared/node_modules' does not exist, skipping all lookups in it.", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "File '/node_modules/pkg/package.json' does not exist.", + "File '/node_modules/pkg.ts' does not exist.", + "File '/node_modules/pkg.tsx' does not exist.", + "File '/node_modules/pkg.d.ts' does not exist.", + "File '/node_modules/pkg/index.ts' does not exist.", + "File '/node_modules/pkg/index.tsx' does not exist.", + "File '/node_modules/pkg/index.d.ts' exists - use it as a name resolution result.", + "Resolving real path for '/node_modules/pkg/index.d.ts', result '/node_modules/pkg/index.d.ts'.", + "======== Module name 'pkg' was successfully resolved to '/node_modules/pkg/index.d.ts'. ========", + "======== Resolving module '@typescript/lib-es5' from '/packages/main/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/packages/main/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/packages/main/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/packages/main/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/packages/main/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/packages/main/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/packages/main/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/packages/main/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/packages/main/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/packages/main/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/packages/main/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/packages/main/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/packages/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/allowJsCrossMonorepoPackage.types b/tests/baselines/reference/allowJsCrossMonorepoPackage.types new file mode 100644 index 0000000000000..8a0ecbf103606 --- /dev/null +++ b/tests/baselines/reference/allowJsCrossMonorepoPackage.types @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/allowJsCrossMonorepoPackage.ts] //// + +=== /packages/main/index.ts === +import { x } from "shared"; +>x : "pkg" + +=== /node_modules/pkg/index.d.ts === +export declare function pkg(): "pkg"; +>pkg : () => "pkg" + +=== /packages/shared/utils.js === +export { pkg } from "pkg"; +>pkg : () => "pkg" + +=== /packages/shared/index.js === +import { pkg } from "./utils.js"; +>pkg : () => "pkg" + +export const x = pkg(); +>x : "pkg" +>pkg() : "pkg" +>pkg : () => "pkg" + diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index c723fbebb0a16..1e433e55d63f3 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2933,6 +2933,13 @@ declare namespace ts { * Default: `false` */ readonly organizeImportsCaseFirst?: "upper" | "lower" | false; + /** + * Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is + * type-only. + * + * Default: `last` + */ + readonly organizeImportsTypeOrder?: "last" | "first" | "inline"; /** * Indicates whether {@link ReferencesResponseItem.lineText} is supported. */ @@ -7069,6 +7076,7 @@ declare namespace ts { Default = "default", This = "this", InstantiationExpression = "__instantiationExpression", + ImportAttributes = "__importAttributes", } /** * This represents a string whose leading underscore have been escaped by adding extra leading underscores. @@ -8784,6 +8792,7 @@ declare namespace ts { readonly organizeImportsNumericCollation?: boolean; readonly organizeImportsAccentCollation?: boolean; readonly organizeImportsCaseFirst?: "upper" | "lower" | false; + readonly organizeImportsTypeOrder?: "first" | "last" | "inline"; readonly excludeLibrarySymbolsInNavTo?: boolean; } /** Represents a bigint literal value without requiring bigint support */ @@ -9189,6 +9198,7 @@ declare namespace ts { function isForInitializer(node: Node): node is ForInitializer; function isModuleBody(node: Node): node is ModuleBody; function isNamedImportBindings(node: Node): node is NamedImportBindings; + function isDeclarationStatement(node: Node): node is DeclarationStatement; function isStatement(node: Node): node is Statement; function isModuleReference(node: Node): node is ModuleReference; function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression; @@ -9208,11 +9218,13 @@ declare namespace ts { function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain; function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean; function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): boolean; + function isInternalDeclaration(node: Node, sourceFile?: SourceFile): boolean; const unchangedTextChangeRange: TextChangeRange; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; }; + function isPartOfTypeNode(node: Node): boolean; /** * 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 @@ -9851,7 +9863,7 @@ declare namespace ts { * @param visitor The callback used to visit each child. * @param context A lexical environment context for the visitor. */ - function visitEachChild(node: T, visitor: Visitor, context: TransformationContext): T; + function visitEachChild(node: T, visitor: Visitor, context: TransformationContext | undefined): T; /** * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. * @@ -9859,7 +9871,7 @@ declare namespace ts { * @param visitor The callback used to visit each child. * @param context A lexical environment context for the visitor. */ - function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; + function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext | undefined, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined; function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[]; function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; diff --git a/tests/baselines/reference/completionListForImportAttributes.baseline b/tests/baselines/reference/completionListForImportAttributes.baseline new file mode 100644 index 0000000000000..2629823d733cd --- /dev/null +++ b/tests/baselines/reference/completionListForImportAttributes.baseline @@ -0,0 +1,334 @@ +// === Completions === +=== /tests/cases/fourslash/./b.ts === +// declare global { +// interface ImportAttributes { +// type: "json", +// "resolution-mode": "import" +// } +// } +// const str = "hello"; +// +// import * as t1 from "./a" with { }; +// ^ +// | ---------------------------------------------------------------------- +// | (property) ImportAttributes["resolution-mode"]: "import" +// | (property) ImportAttributes.type: "json" +// | ---------------------------------------------------------------------- +// import * as t2 from "./a" with { type: "" }; +// ^ +// | ---------------------------------------------------------------------- +// | json +// | ---------------------------------------------------------------------- +// import * as t3 from "./a" with { type: "json", }; +// ^ +// | ---------------------------------------------------------------------- +// | (property) ImportAttributes["resolution-mode"]: "import" +// | ---------------------------------------------------------------------- +// import * as t4 from "./a" with { type: }; +// ^ +// | ---------------------------------------------------------------------- +// | "json" +// | (property) ImportAttributes["resolution-mode"]: "import" +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/./b.ts", + "position": 171, + "name": "1" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": false, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "resolution-mode", + "kind": "property", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ImportAttributes", + "kind": "interfaceName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "\"resolution-mode\"", + "kind": "stringLiteral" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"import\"", + "kind": "stringLiteral" + } + ], + "documentation": [] + }, + { + "name": "type", + "kind": "property", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ImportAttributes", + "kind": "interfaceName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "type", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"json\"", + "kind": "stringLiteral" + } + ], + "documentation": [] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/./b.ts", + "position": 215, + "name": "2" + }, + "item": { + "isGlobalCompletion": false, + "isMemberCompletion": false, + "isNewIdentifierLocation": false, + "optionalReplacementSpan": { + "start": 215, + "length": 0 + }, + "entries": [ + { + "name": "json", + "kindModifiers": "", + "kind": "string", + "sortText": "11", + "replacementSpan": { + "start": 215, + "length": 0 + }, + "displayParts": [ + { + "text": "json", + "kind": "text" + } + ] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/./b.ts", + "position": 267, + "name": "3" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": false, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "resolution-mode", + "kind": "property", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ImportAttributes", + "kind": "interfaceName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "\"resolution-mode\"", + "kind": "stringLiteral" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"import\"", + "kind": "stringLiteral" + } + ], + "documentation": [] + } + ] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/./b.ts", + "position": 310, + "name": "4" + }, + "item": { + "flags": 0, + "isGlobalCompletion": false, + "isMemberCompletion": false, + "isNewIdentifierLocation": false, + "entries": [ + { + "name": "\"json\"", + "kind": "string", + "kindModifiers": "", + "sortText": "11", + "displayParts": [ + { + "text": "\"json\"", + "kind": "stringLiteral" + } + ] + }, + { + "name": "resolution-mode", + "kind": "property", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ImportAttributes", + "kind": "interfaceName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "\"resolution-mode\"", + "kind": "stringLiteral" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"import\"", + "kind": "stringLiteral" + } + ], + "documentation": [] + } + ] + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/completionPropertyFromConstraint.baseline b/tests/baselines/reference/completionPropertyFromConstraint.baseline index 210d913dabee3..a31f3e0646c99 100644 --- a/tests/baselines/reference/completionPropertyFromConstraint.baseline +++ b/tests/baselines/reference/completionPropertyFromConstraint.baseline @@ -17,7 +17,7 @@ // createStyles({ // x: { // '': '' -// +// ^ // | ---------------------------------------------------------------------- // | (property) alignContent?: string // | (property) alignItems?: string diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js index 68ab2d4176968..cd421cd200b7c 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js @@ -10,4 +10,4 @@ WatchOptions:: FileNames:: es7,0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js index 0e0b1480091fe..fabeb52959d52 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js @@ -10,4 +10,4 @@ WatchOptions:: FileNames:: es7,0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js index 6942908118197..e0e3de1debba3 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js @@ -10,4 +10,4 @@ WatchOptions:: FileNames:: 0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js index a5bb63eac24d9..347aaaaff50d1 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js @@ -30,5 +30,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js index 18a774c865aa2..2318431048871 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js @@ -30,7 +30,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:8:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +tsconfig.json:8:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. 8 ""    ~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js index 36d03b9fb774b..29e437f45f1f4 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js @@ -33,5 +33,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js index 089cd767e35d0..2576767fca19d 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js @@ -33,7 +33,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:9:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +tsconfig.json:9:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. 9 ""    ~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js index b1087ce9efa20..d416471d82cc8 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js @@ -35,5 +35,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js index 50369fce5d9ac..751b7b61ae565 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js @@ -35,7 +35,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:10:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +tsconfig.json:10:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. 10 "incorrectLib"    ~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js index 8b7433122f6b7..64fc869bb68ac 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js @@ -30,5 +30,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js index 1d680893a6bbf..833000aa896cf 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js @@ -30,7 +30,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:8:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'. +tsconfig.json:8:7 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'. 8 " "    ~~~~~ diff --git a/tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.js b/tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.js new file mode 100644 index 0000000000000..cb2a774fe5036 --- /dev/null +++ b/tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.js @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/declarationEmitBindingPatternsFunctionExpr.ts] //// + +//// [declarationEmitBindingPatternsFunctionExpr.ts] +type Named = { name: string } +// Tempting to remove alias if unused +let notReferenced = ({ name: alias }: Named) => { } + +// Resons we can't remove aliases that are not used in the function signature: + +// 1.Causes duplicate identifier if we remove alias +const duplicateIndetifiers = ({ name: alias, name: alias2 }: Named) => { } +const duplicateIndetifiers2 = (name: string, { name: alias }: Named) => { } +const duplicateIndetifiers3 = ({ name: alias }: Named, { name: alias2 }: Named) => { } + +let value = ""; +// 2.Can change in meaning for typeof value if we remove alias +const shadowedVariable = ({ value: alias }: { value: string }): typeof value => value; + +//// [declarationEmitBindingPatternsFunctionExpr.js] +// Tempting to remove alias if unused +let notReferenced = ({ name: alias }) => { }; +// Resons we can't remove aliases that are not used in the function signature: +// 1.Causes duplicate identifier if we remove alias +const duplicateIndetifiers = ({ name: alias, name: alias2 }) => { }; +const duplicateIndetifiers2 = (name, { name: alias }) => { }; +const duplicateIndetifiers3 = ({ name: alias }, { name: alias2 }) => { }; +let value = ""; +// 2.Can change in meaning for typeof value if we remove alias +const shadowedVariable = ({ value: alias }) => value; + + +//// [declarationEmitBindingPatternsFunctionExpr.d.ts] +type Named = { + name: string; +}; +declare let notReferenced: ({ name: alias }: Named) => void; +declare const duplicateIndetifiers: ({ name: alias, name: alias2 }: Named) => void; +declare const duplicateIndetifiers2: (name: string, { name: alias }: Named) => void; +declare const duplicateIndetifiers3: ({ name: alias }: Named, { name: alias2 }: Named) => void; +declare let value: string; +declare const shadowedVariable: ({ value: alias }: { + value: string; +}) => typeof value; diff --git a/tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.symbols b/tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.symbols new file mode 100644 index 0000000000000..51b5dc159420f --- /dev/null +++ b/tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.symbols @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/declarationEmitBindingPatternsFunctionExpr.ts] //// + +=== declarationEmitBindingPatternsFunctionExpr.ts === +type Named = { name: string } +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) + +// Tempting to remove alias if unused +let notReferenced = ({ name: alias }: Named) => { } +>notReferenced : Symbol(notReferenced, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 2, 3)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 2, 22)) +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) + +// Resons we can't remove aliases that are not used in the function signature: + +// 1.Causes duplicate identifier if we remove alias +const duplicateIndetifiers = ({ name: alias, name: alias2 }: Named) => { } +>duplicateIndetifiers : Symbol(duplicateIndetifiers, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 7, 5)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 7, 31)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) +>alias2 : Symbol(alias2, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 7, 44)) +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) + +const duplicateIndetifiers2 = (name: string, { name: alias }: Named) => { } +>duplicateIndetifiers2 : Symbol(duplicateIndetifiers2, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 8, 5)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 8, 31)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 8, 46)) +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) + +const duplicateIndetifiers3 = ({ name: alias }: Named, { name: alias2 }: Named) => { } +>duplicateIndetifiers3 : Symbol(duplicateIndetifiers3, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 9, 5)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 9, 32)) +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) +>alias2 : Symbol(alias2, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 9, 56)) +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) + +let value = ""; +>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 11, 3)) + +// 2.Can change in meaning for typeof value if we remove alias +const shadowedVariable = ({ value: alias }: { value: string }): typeof value => value; +>shadowedVariable : Symbol(shadowedVariable, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 13, 5)) +>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 13, 45)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 13, 27)) +>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 13, 45)) +>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 11, 3)) +>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 11, 3)) + diff --git a/tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.types b/tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.types new file mode 100644 index 0000000000000..aae3e8a40a4e1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.types @@ -0,0 +1,54 @@ +//// [tests/cases/compiler/declarationEmitBindingPatternsFunctionExpr.ts] //// + +=== declarationEmitBindingPatternsFunctionExpr.ts === +type Named = { name: string } +>Named : { name: string; } +>name : string + +// Tempting to remove alias if unused +let notReferenced = ({ name: alias }: Named) => { } +>notReferenced : ({ name: alias }: Named) => void +>({ name: alias }: Named) => { } : ({ name: alias }: Named) => void +>name : any +>alias : string + +// Resons we can't remove aliases that are not used in the function signature: + +// 1.Causes duplicate identifier if we remove alias +const duplicateIndetifiers = ({ name: alias, name: alias2 }: Named) => { } +>duplicateIndetifiers : ({ name: alias, name: alias2 }: Named) => void +>({ name: alias, name: alias2 }: Named) => { } : ({ name: alias, name: alias2 }: Named) => void +>name : any +>alias : string +>name : any +>alias2 : string + +const duplicateIndetifiers2 = (name: string, { name: alias }: Named) => { } +>duplicateIndetifiers2 : (name: string, { name: alias }: Named) => void +>(name: string, { name: alias }: Named) => { } : (name: string, { name: alias }: Named) => void +>name : string +>name : any +>alias : string + +const duplicateIndetifiers3 = ({ name: alias }: Named, { name: alias2 }: Named) => { } +>duplicateIndetifiers3 : ({ name: alias }: Named, { name: alias2 }: Named) => void +>({ name: alias }: Named, { name: alias2 }: Named) => { } : ({ name: alias }: Named, { name: alias2 }: Named) => void +>name : any +>alias : string +>name : any +>alias2 : string + +let value = ""; +>value : string +>"" : "" + +// 2.Can change in meaning for typeof value if we remove alias +const shadowedVariable = ({ value: alias }: { value: string }): typeof value => value; +>shadowedVariable : ({ value: alias }: { value: string;}) => typeof value +>({ value: alias }: { value: string }): typeof value => value : ({ value: alias }: { value: string;}) => typeof value +>value : any +>alias : string +>value : string +>value : string +>value : string + diff --git a/tests/baselines/reference/declarationEmitBindingPatternsUnused.errors.txt b/tests/baselines/reference/declarationEmitBindingPatternsUnused.errors.txt index 84bfe180d0084..0dc2e5589942d 100644 --- a/tests/baselines/reference/declarationEmitBindingPatternsUnused.errors.txt +++ b/tests/baselines/reference/declarationEmitBindingPatternsUnused.errors.txt @@ -1,13 +1,25 @@ -declarationEmitBindingPatternsUnused.ts(85,35): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? -declarationEmitBindingPatternsUnused.ts(89,41): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? -declarationEmitBindingPatternsUnused.ts(95,11): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? -declarationEmitBindingPatternsUnused.ts(96,15): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? -declarationEmitBindingPatternsUnused.ts(97,16): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? -declarationEmitBindingPatternsUnused.ts(98,12): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? +declarationEmitBindingPatternsUnused.ts(95,35): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? +declarationEmitBindingPatternsUnused.ts(99,41): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? +declarationEmitBindingPatternsUnused.ts(105,11): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? +declarationEmitBindingPatternsUnused.ts(106,15): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? +declarationEmitBindingPatternsUnused.ts(107,16): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? +declarationEmitBindingPatternsUnused.ts(108,12): error TS2842: 'alias' is an unused renaming of 'name'. Did you intend to use it as a type annotation? ==== declarationEmitBindingPatternsUnused.ts (6 errors) ==== type Named = { name: string } + + // Resons we can't remove aliases that are not used in the function signature: + + // 1.Causes duplicate identifier if we remove alias + function duplicateIndetifiers({ name: alias, name: alias2 }: Named) { } + function duplicateIndetifiers2(name: string, { name: alias }: Named) { } + function duplicateIndetifiers3({ name: alias }: Named, { name: alias2 }: Named) { } + + let value = ""; + // 2.Can change in meaning for typeof value if we remove alias + function shadowedVariable({ value: alias }: { value: string }): typeof value { return value } + function notReferenced({ name: alias }: Named) { } @@ -16,8 +28,6 @@ declarationEmitBindingPatternsUnused.ts(98,12): error TS2842: 'alias' is an unus function notReferencedArrayAlias([a, b, { name: alias }]: Named[]) { } - - function referencedInCode({ name: alias }: Named) { return alias; } diff --git a/tests/baselines/reference/declarationEmitBindingPatternsUnused.js b/tests/baselines/reference/declarationEmitBindingPatternsUnused.js index 79c2ea8520b8b..3452e6cc8b0e8 100644 --- a/tests/baselines/reference/declarationEmitBindingPatternsUnused.js +++ b/tests/baselines/reference/declarationEmitBindingPatternsUnused.js @@ -2,6 +2,18 @@ //// [declarationEmitBindingPatternsUnused.ts] type Named = { name: string } + +// Resons we can't remove aliases that are not used in the function signature: + +// 1.Causes duplicate identifier if we remove alias +function duplicateIndetifiers({ name: alias, name: alias2 }: Named) { } +function duplicateIndetifiers2(name: string, { name: alias }: Named) { } +function duplicateIndetifiers3({ name: alias }: Named, { name: alias2 }: Named) { } + +let value = ""; +// 2.Can change in meaning for typeof value if we remove alias +function shadowedVariable({ value: alias }: { value: string }): typeof value { return value } + function notReferenced({ name: alias }: Named) { } @@ -10,8 +22,6 @@ function notReferencedNestedAlias({ p: { name: alias } }: { p: Named }) { function notReferencedArrayAlias([a, b, { name: alias }]: Named[]) { } - - function referencedInCode({ name: alias }: Named) { return alias; } @@ -114,6 +124,14 @@ interface ReferencedInSignartureInterface { } //// [declarationEmitBindingPatternsUnused.js] +// Resons we can't remove aliases that are not used in the function signature: +// 1.Causes duplicate identifier if we remove alias +function duplicateIndetifiers({ name: alias, name: alias2 }) { } +function duplicateIndetifiers2(name, { name: alias }) { } +function duplicateIndetifiers3({ name: alias }, { name: alias2 }) { } +let value = ""; +// 2.Can change in meaning for typeof value if we remove alias +function shadowedVariable({ value: alias }) { return value; } function notReferenced({ name: alias }) { } function notReferencedNestedAlias({ p: { name: alias } }) { @@ -191,12 +209,19 @@ let referencedInSignartureParamTypeCtorType; type Named = { name: string; }; -declare function notReferenced({ name }: Named): void; -declare function notReferencedNestedAlias({ p: { name } }: { +declare function duplicateIndetifiers({ name: alias, name: alias2 }: Named): void; +declare function duplicateIndetifiers2(name: string, { name: alias }: Named): void; +declare function duplicateIndetifiers3({ name: alias }: Named, { name: alias2 }: Named): void; +declare let value: string; +declare function shadowedVariable({ value: alias }: { + value: string; +}): typeof value; +declare function notReferenced({ name: alias }: Named): void; +declare function notReferencedNestedAlias({ p: { name: alias } }: { p: Named; }): void; -declare function notReferencedArrayAlias([a, b, { name }]: Named[]): void; -declare function referencedInCode({ name }: Named): string; +declare function notReferencedArrayAlias([a, b, { name: alias }]: Named[]): void; +declare function referencedInCode({ name: alias }: Named): string; declare function referencedInSignarture({ name: alias }: Named): typeof alias; declare function referencedInSignartureKeyword({ function: alias }: { function: string; @@ -210,14 +235,14 @@ declare function referencedNestedAlias({ p: { name: alias } }: { }): typeof alias; declare function referencedArrayAlias([a, b, { name: alias }]: Named[]): typeof alias; declare class NotReferencedClass { - constructor({ name }: Named); - set x({ name }: Named); - m({ name }: Named): void; + constructor({ name: alias }: Named); + set x({ name: alias }: Named); + m({ name: alias }: Named): void; } declare class ReferencedInCodeClas { - constructor({ name }: Named); - set x({ name }: Named); - m({ name }: Named): void; + constructor({ name: alias }: Named); + set x({ name: alias }: Named); + m({ name: alias }: Named): void; } declare class ReferencedInSignartureClass { constructor({ name: alias }: Named, p: typeof alias); @@ -228,17 +253,17 @@ declare class ReferencedInSignartureClass { mRerturnTypeNested({ name: alias }: Named): NonNullable; mParameter({ name: alias }: Named, p: typeof alias): any; } -declare let notReferencedFnType: ({ name }: Named) => void; +declare let notReferencedFnType: ({ name: alias }: Named) => void; declare let referencedInSignartureReturnTypeFnType: ({ name: alias }: Named) => typeof alias; declare let referencedInSignartureParamTypeFnType: ({ name: alias }: Named, p: typeof alias) => void; -declare let notReferencedCtorType: new ({ name }: Named) => void; +declare let notReferencedCtorType: new ({ name: alias }: Named) => void; declare let referencedInSignartureReturnTypeCtorType: new ({ name: alias }: Named) => typeof alias; declare let referencedInSignartureParamTypeCtorType: new ({ name: alias }: Named, p: typeof alias) => void; interface NotReferencedInterface { - ({ name }: Named): void; - new ({ name }: Named): void; - set x({ name }: Named); - m({ name }: Named): any; + ({ name: alias }: Named): void; + new ({ name: alias }: Named): void; + set x({ name: alias }: Named); + m({ name: alias }: Named): any; } interface ReferencedInSignartureInterface { ({ name: alias }: Named, p: typeof alias): void; diff --git a/tests/baselines/reference/declarationEmitBindingPatternsUnused.symbols b/tests/baselines/reference/declarationEmitBindingPatternsUnused.symbols index 809cf5683cd21..4e0d43f0dc7ce 100644 --- a/tests/baselines/reference/declarationEmitBindingPatternsUnused.symbols +++ b/tests/baselines/reference/declarationEmitBindingPatternsUnused.symbols @@ -5,374 +5,411 @@ type Named = { name: string } >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) +// Resons we can't remove aliases that are not used in the function signature: + +// 1.Causes duplicate identifier if we remove alias +function duplicateIndetifiers({ name: alias, name: alias2 }: Named) { } +>duplicateIndetifiers : Symbol(duplicateIndetifiers, Decl(declarationEmitBindingPatternsUnused.ts, 0, 29)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 5, 31)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) +>alias2 : Symbol(alias2, Decl(declarationEmitBindingPatternsUnused.ts, 5, 44)) +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) + +function duplicateIndetifiers2(name: string, { name: alias }: Named) { } +>duplicateIndetifiers2 : Symbol(duplicateIndetifiers2, Decl(declarationEmitBindingPatternsUnused.ts, 5, 71)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 6, 31)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 6, 46)) +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) + +function duplicateIndetifiers3({ name: alias }: Named, { name: alias2 }: Named) { } +>duplicateIndetifiers3 : Symbol(duplicateIndetifiers3, Decl(declarationEmitBindingPatternsUnused.ts, 6, 72)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 7, 32)) +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) +>alias2 : Symbol(alias2, Decl(declarationEmitBindingPatternsUnused.ts, 7, 56)) +>Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) + +let value = ""; +>value : Symbol(value, Decl(declarationEmitBindingPatternsUnused.ts, 9, 3)) + +// 2.Can change in meaning for typeof value if we remove alias +function shadowedVariable({ value: alias }: { value: string }): typeof value { return value } +>shadowedVariable : Symbol(shadowedVariable, Decl(declarationEmitBindingPatternsUnused.ts, 9, 15)) +>value : Symbol(value, Decl(declarationEmitBindingPatternsUnused.ts, 11, 45)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 11, 27)) +>value : Symbol(value, Decl(declarationEmitBindingPatternsUnused.ts, 11, 45)) +>value : Symbol(value, Decl(declarationEmitBindingPatternsUnused.ts, 9, 3)) +>value : Symbol(value, Decl(declarationEmitBindingPatternsUnused.ts, 9, 3)) + function notReferenced({ name: alias }: Named) { ->notReferenced : Symbol(notReferenced, Decl(declarationEmitBindingPatternsUnused.ts, 0, 29)) +>notReferenced : Symbol(notReferenced, Decl(declarationEmitBindingPatternsUnused.ts, 11, 93)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 1, 24)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 13, 24)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) } function notReferencedNestedAlias({ p: { name: alias } }: { p: Named }) { ->notReferencedNestedAlias : Symbol(notReferencedNestedAlias, Decl(declarationEmitBindingPatternsUnused.ts, 3, 1)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 4, 59)) +>notReferencedNestedAlias : Symbol(notReferencedNestedAlias, Decl(declarationEmitBindingPatternsUnused.ts, 15, 1)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 16, 59)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 4, 40)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 4, 59)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 16, 40)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 16, 59)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) } function notReferencedArrayAlias([a, b, { name: alias }]: Named[]) { ->notReferencedArrayAlias : Symbol(notReferencedArrayAlias, Decl(declarationEmitBindingPatternsUnused.ts, 5, 1)) ->a : Symbol(a, Decl(declarationEmitBindingPatternsUnused.ts, 6, 34)) ->b : Symbol(b, Decl(declarationEmitBindingPatternsUnused.ts, 6, 36)) +>notReferencedArrayAlias : Symbol(notReferencedArrayAlias, Decl(declarationEmitBindingPatternsUnused.ts, 17, 1)) +>a : Symbol(a, Decl(declarationEmitBindingPatternsUnused.ts, 18, 34)) +>b : Symbol(b, Decl(declarationEmitBindingPatternsUnused.ts, 18, 36)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 6, 41)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 18, 41)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) } - - function referencedInCode({ name: alias }: Named) { ->referencedInCode : Symbol(referencedInCode, Decl(declarationEmitBindingPatternsUnused.ts, 7, 1)) +>referencedInCode : Symbol(referencedInCode, Decl(declarationEmitBindingPatternsUnused.ts, 19, 1)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 11, 27)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 21, 27)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) return alias; ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 11, 27)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 21, 27)) } function referencedInSignarture({ name: alias }: Named): typeof alias { ->referencedInSignarture : Symbol(referencedInSignarture, Decl(declarationEmitBindingPatternsUnused.ts, 13, 1)) +>referencedInSignarture : Symbol(referencedInSignarture, Decl(declarationEmitBindingPatternsUnused.ts, 23, 1)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 15, 33)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 25, 33)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 15, 33)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 25, 33)) return alias; ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 15, 33)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 25, 33)) } function referencedInSignartureKeyword({ function: alias }: { function: string }): typeof alias { ->referencedInSignartureKeyword : Symbol(referencedInSignartureKeyword, Decl(declarationEmitBindingPatternsUnused.ts, 17, 1)) ->function : Symbol(function, Decl(declarationEmitBindingPatternsUnused.ts, 19, 61)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 19, 40)) ->function : Symbol(function, Decl(declarationEmitBindingPatternsUnused.ts, 19, 61)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 19, 40)) +>referencedInSignartureKeyword : Symbol(referencedInSignartureKeyword, Decl(declarationEmitBindingPatternsUnused.ts, 27, 1)) +>function : Symbol(function, Decl(declarationEmitBindingPatternsUnused.ts, 29, 61)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 29, 40)) +>function : Symbol(function, Decl(declarationEmitBindingPatternsUnused.ts, 29, 61)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 29, 40)) return null!; } function referencedInInferredType({ name: alias }: Named) { ->referencedInInferredType : Symbol(referencedInInferredType, Decl(declarationEmitBindingPatternsUnused.ts, 21, 1)) +>referencedInInferredType : Symbol(referencedInInferredType, Decl(declarationEmitBindingPatternsUnused.ts, 31, 1)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 23, 35)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 33, 35)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) type Named2 = { name: typeof alias } ->Named2 : Symbol(Named2, Decl(declarationEmitBindingPatternsUnused.ts, 23, 59)) ->name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 24, 19)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 23, 35)) +>Named2 : Symbol(Named2, Decl(declarationEmitBindingPatternsUnused.ts, 33, 59)) +>name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 34, 19)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 33, 35)) return null! as Named2 ->Named2 : Symbol(Named2, Decl(declarationEmitBindingPatternsUnused.ts, 23, 59)) +>Named2 : Symbol(Named2, Decl(declarationEmitBindingPatternsUnused.ts, 33, 59)) } function referencedInNestedFunction({ name: alias }: Named) { ->referencedInNestedFunction : Symbol(referencedInNestedFunction, Decl(declarationEmitBindingPatternsUnused.ts, 26, 1)) +>referencedInNestedFunction : Symbol(referencedInNestedFunction, Decl(declarationEmitBindingPatternsUnused.ts, 36, 1)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 28, 37)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 38, 37)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) return function(p: typeof alias) { ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 29, 20)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 28, 37)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 39, 20)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 38, 37)) } } function referencedNestedAlias({ p: { name: alias } }: { p: Named }): typeof alias { ->referencedNestedAlias : Symbol(referencedNestedAlias, Decl(declarationEmitBindingPatternsUnused.ts, 32, 1)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 34, 56)) +>referencedNestedAlias : Symbol(referencedNestedAlias, Decl(declarationEmitBindingPatternsUnused.ts, 42, 1)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 44, 56)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 34, 37)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 34, 56)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 44, 37)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 44, 56)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 34, 37)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 44, 37)) return alias; ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 34, 37)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 44, 37)) } function referencedArrayAlias([a, b, { name: alias }]: Named[]): typeof alias { ->referencedArrayAlias : Symbol(referencedArrayAlias, Decl(declarationEmitBindingPatternsUnused.ts, 36, 1)) ->a : Symbol(a, Decl(declarationEmitBindingPatternsUnused.ts, 38, 31)) ->b : Symbol(b, Decl(declarationEmitBindingPatternsUnused.ts, 38, 33)) +>referencedArrayAlias : Symbol(referencedArrayAlias, Decl(declarationEmitBindingPatternsUnused.ts, 46, 1)) +>a : Symbol(a, Decl(declarationEmitBindingPatternsUnused.ts, 48, 31)) +>b : Symbol(b, Decl(declarationEmitBindingPatternsUnused.ts, 48, 33)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 38, 38)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 48, 38)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 38, 38)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 48, 38)) return alias; ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 38, 38)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 48, 38)) } class NotReferencedClass { ->NotReferencedClass : Symbol(NotReferencedClass, Decl(declarationEmitBindingPatternsUnused.ts, 40, 1)) +>NotReferencedClass : Symbol(NotReferencedClass, Decl(declarationEmitBindingPatternsUnused.ts, 50, 1)) constructor({ name: alias }: Named) { >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 44, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 54, 14)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) } set x({ name: alias }: Named) { ->x : Symbol(NotReferencedClass.x, Decl(declarationEmitBindingPatternsUnused.ts, 45, 2)) +>x : Symbol(NotReferencedClass.x, Decl(declarationEmitBindingPatternsUnused.ts, 55, 2)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 46, 8)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 56, 8)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) console.log(alias); >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, --, --)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 46, 8)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 56, 8)) } m({ name: alias }: Named) { ->m : Symbol(NotReferencedClass.m, Decl(declarationEmitBindingPatternsUnused.ts, 48, 5)) +>m : Symbol(NotReferencedClass.m, Decl(declarationEmitBindingPatternsUnused.ts, 58, 5)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 49, 4)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 59, 4)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) console.log(alias); >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, --, --)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 49, 4)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 59, 4)) } } class ReferencedInCodeClas { ->ReferencedInCodeClas : Symbol(ReferencedInCodeClas, Decl(declarationEmitBindingPatternsUnused.ts, 52, 1)) +>ReferencedInCodeClas : Symbol(ReferencedInCodeClas, Decl(declarationEmitBindingPatternsUnused.ts, 62, 1)) constructor({ name: alias }: Named) { >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 55, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 65, 14)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) console.log(alias); >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, --, --)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 55, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 65, 14)) } set x({ name: alias }: Named) { ->x : Symbol(ReferencedInCodeClas.x, Decl(declarationEmitBindingPatternsUnused.ts, 57, 2)) +>x : Symbol(ReferencedInCodeClas.x, Decl(declarationEmitBindingPatternsUnused.ts, 67, 2)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 58, 8)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 68, 8)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) console.log(alias); >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, --, --)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 58, 8)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 68, 8)) } m({ name: alias }: Named) { ->m : Symbol(ReferencedInCodeClas.m, Decl(declarationEmitBindingPatternsUnused.ts, 60, 5)) +>m : Symbol(ReferencedInCodeClas.m, Decl(declarationEmitBindingPatternsUnused.ts, 70, 5)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 61, 4)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 71, 4)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) console.log(alias); >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, --, --)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 61, 4)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 71, 4)) } } class ReferencedInSignartureClass { ->ReferencedInSignartureClass : Symbol(ReferencedInSignartureClass, Decl(declarationEmitBindingPatternsUnused.ts, 64, 1)) +>ReferencedInSignartureClass : Symbol(ReferencedInSignartureClass, Decl(declarationEmitBindingPatternsUnused.ts, 74, 1)) constructor({ name: alias }: Named, p: typeof alias) { >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 67, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 77, 14)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 67, 36)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 67, 14)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 77, 36)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 77, 14)) console.log(alias); >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, --, --)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 67, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 77, 14)) } set x({ name: alias }: Named & { o: typeof alias }) { ->x : Symbol(ReferencedInSignartureClass.x, Decl(declarationEmitBindingPatternsUnused.ts, 69, 2)) +>x : Symbol(ReferencedInSignartureClass.x, Decl(declarationEmitBindingPatternsUnused.ts, 79, 2)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 70, 8)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 80, 8)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->o : Symbol(o, Decl(declarationEmitBindingPatternsUnused.ts, 70, 33)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 70, 8)) +>o : Symbol(o, Decl(declarationEmitBindingPatternsUnused.ts, 80, 33)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 80, 8)) } mReturnType({ name: alias }: Named): typeof alias { ->mReturnType : Symbol(ReferencedInSignartureClass.mReturnType, Decl(declarationEmitBindingPatternsUnused.ts, 72, 5)) +>mReturnType : Symbol(ReferencedInSignartureClass.mReturnType, Decl(declarationEmitBindingPatternsUnused.ts, 82, 5)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 73, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 83, 14)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 73, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 83, 14)) return null! } mRerturnTypeNested({ name: alias }: Named): NonNullable { ->mRerturnTypeNested : Symbol(ReferencedInSignartureClass.mRerturnTypeNested, Decl(declarationEmitBindingPatternsUnused.ts, 75, 5)) +>mRerturnTypeNested : Symbol(ReferencedInSignartureClass.mRerturnTypeNested, Decl(declarationEmitBindingPatternsUnused.ts, 85, 5)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 76, 21)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 86, 21)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) >NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 76, 21)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 86, 21)) return null! } mParameter({ name: alias }: Named, p: typeof alias) { ->mParameter : Symbol(ReferencedInSignartureClass.mParameter, Decl(declarationEmitBindingPatternsUnused.ts, 78, 5)) +>mParameter : Symbol(ReferencedInSignartureClass.mParameter, Decl(declarationEmitBindingPatternsUnused.ts, 88, 5)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 79, 16)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 89, 16)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 79, 38)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 79, 16)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 89, 38)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 89, 16)) return null! } } let notReferencedFnType: ({ name: alias }: Named) => void; ->notReferencedFnType : Symbol(notReferencedFnType, Decl(declarationEmitBindingPatternsUnused.ts, 84, 3)) +>notReferencedFnType : Symbol(notReferencedFnType, Decl(declarationEmitBindingPatternsUnused.ts, 94, 3)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 84, 27)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 94, 27)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) let referencedInSignartureReturnTypeFnType: ({ name: alias }: Named) => typeof alias; ->referencedInSignartureReturnTypeFnType : Symbol(referencedInSignartureReturnTypeFnType, Decl(declarationEmitBindingPatternsUnused.ts, 85, 3)) +>referencedInSignartureReturnTypeFnType : Symbol(referencedInSignartureReturnTypeFnType, Decl(declarationEmitBindingPatternsUnused.ts, 95, 3)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 85, 46)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 95, 46)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 85, 46)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 95, 46)) let referencedInSignartureParamTypeFnType: ({ name: alias }: Named, p: typeof alias) => void; ->referencedInSignartureParamTypeFnType : Symbol(referencedInSignartureParamTypeFnType, Decl(declarationEmitBindingPatternsUnused.ts, 86, 3)) +>referencedInSignartureParamTypeFnType : Symbol(referencedInSignartureParamTypeFnType, Decl(declarationEmitBindingPatternsUnused.ts, 96, 3)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 86, 45)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 96, 45)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 86, 67)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 86, 45)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 96, 67)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 96, 45)) let notReferencedCtorType: new ({ name: alias }: Named) => void; ->notReferencedCtorType : Symbol(notReferencedCtorType, Decl(declarationEmitBindingPatternsUnused.ts, 88, 3)) +>notReferencedCtorType : Symbol(notReferencedCtorType, Decl(declarationEmitBindingPatternsUnused.ts, 98, 3)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 88, 33)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 98, 33)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) let referencedInSignartureReturnTypeCtorType: new ({ name: alias }: Named) => typeof alias; ->referencedInSignartureReturnTypeCtorType : Symbol(referencedInSignartureReturnTypeCtorType, Decl(declarationEmitBindingPatternsUnused.ts, 89, 3)) +>referencedInSignartureReturnTypeCtorType : Symbol(referencedInSignartureReturnTypeCtorType, Decl(declarationEmitBindingPatternsUnused.ts, 99, 3)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 89, 52)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 99, 52)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 89, 52)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 99, 52)) let referencedInSignartureParamTypeCtorType: new ({ name: alias }: Named, p: typeof alias) => void; ->referencedInSignartureParamTypeCtorType : Symbol(referencedInSignartureParamTypeCtorType, Decl(declarationEmitBindingPatternsUnused.ts, 90, 3)) +>referencedInSignartureParamTypeCtorType : Symbol(referencedInSignartureParamTypeCtorType, Decl(declarationEmitBindingPatternsUnused.ts, 100, 3)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 90, 52)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 100, 52)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 90, 74)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 90, 52)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 100, 74)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 100, 52)) interface NotReferencedInterface { ->NotReferencedInterface : Symbol(NotReferencedInterface, Decl(declarationEmitBindingPatternsUnused.ts, 90, 100)) +>NotReferencedInterface : Symbol(NotReferencedInterface, Decl(declarationEmitBindingPatternsUnused.ts, 100, 100)) ({ name: alias }: Named): void >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 94, 3)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 104, 3)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) new ({ name: alias }: Named): void >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 95, 7)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 105, 7)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) set x({ name: alias }: Named); ->x : Symbol(NotReferencedInterface.x, Decl(declarationEmitBindingPatternsUnused.ts, 95, 35)) +>x : Symbol(NotReferencedInterface.x, Decl(declarationEmitBindingPatternsUnused.ts, 105, 35)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 96, 8)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 106, 8)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) m({ name: alias }: Named); ->m : Symbol(NotReferencedInterface.m, Decl(declarationEmitBindingPatternsUnused.ts, 96, 31)) +>m : Symbol(NotReferencedInterface.m, Decl(declarationEmitBindingPatternsUnused.ts, 106, 31)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 97, 4)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 107, 4)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) } interface ReferencedInSignartureInterface { ->ReferencedInSignartureInterface : Symbol(ReferencedInSignartureInterface, Decl(declarationEmitBindingPatternsUnused.ts, 98, 1)) +>ReferencedInSignartureInterface : Symbol(ReferencedInSignartureInterface, Decl(declarationEmitBindingPatternsUnused.ts, 108, 1)) ({ name: alias }: Named, p: typeof alias): void >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 101, 3)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 111, 3)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 101, 25)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 101, 3)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 111, 25)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 111, 3)) ({ name: alias }: Named): typeof alias >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 102, 3)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 112, 3)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 102, 3)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 112, 3)) new ({ name: alias }: Named, p: typeof alias): void >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 104, 7)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 114, 7)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 104, 29)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 104, 7)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 114, 29)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 114, 7)) new ({ name: alias }: Named): typeof alias >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 105, 7)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 115, 7)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 105, 7)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 115, 7)) set x({ name: alias }: Named & { o: typeof alias }) ->x : Symbol(ReferencedInSignartureInterface.x, Decl(declarationEmitBindingPatternsUnused.ts, 105, 43)) +>x : Symbol(ReferencedInSignartureInterface.x, Decl(declarationEmitBindingPatternsUnused.ts, 115, 43)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 106, 8)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 116, 8)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->o : Symbol(o, Decl(declarationEmitBindingPatternsUnused.ts, 106, 33)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 106, 8)) +>o : Symbol(o, Decl(declarationEmitBindingPatternsUnused.ts, 116, 33)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 116, 8)) mReturnType({ name: alias }: Named): typeof alias; ->mReturnType : Symbol(ReferencedInSignartureInterface.mReturnType, Decl(declarationEmitBindingPatternsUnused.ts, 106, 52)) +>mReturnType : Symbol(ReferencedInSignartureInterface.mReturnType, Decl(declarationEmitBindingPatternsUnused.ts, 116, 52)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 107, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 117, 14)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 107, 14)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 117, 14)) mRerturnTypeNested({ name: alias }: Named): NonNullable; ->mRerturnTypeNested : Symbol(ReferencedInSignartureInterface.mRerturnTypeNested, Decl(declarationEmitBindingPatternsUnused.ts, 107, 51)) +>mRerturnTypeNested : Symbol(ReferencedInSignartureInterface.mRerturnTypeNested, Decl(declarationEmitBindingPatternsUnused.ts, 117, 51)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 108, 21)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 118, 21)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) >NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 108, 21)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 118, 21)) mParameter({ name: alias }: Named, p: typeof alias); ->mParameter : Symbol(ReferencedInSignartureInterface.mParameter, Decl(declarationEmitBindingPatternsUnused.ts, 108, 71)) +>mParameter : Symbol(ReferencedInSignartureInterface.mParameter, Decl(declarationEmitBindingPatternsUnused.ts, 118, 71)) >name : Symbol(name, Decl(declarationEmitBindingPatternsUnused.ts, 0, 14)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 109, 16)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 119, 16)) >Named : Symbol(Named, Decl(declarationEmitBindingPatternsUnused.ts, 0, 0)) ->p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 109, 38)) ->alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 109, 16)) +>p : Symbol(p, Decl(declarationEmitBindingPatternsUnused.ts, 119, 38)) +>alias : Symbol(alias, Decl(declarationEmitBindingPatternsUnused.ts, 119, 16)) } diff --git a/tests/baselines/reference/declarationEmitBindingPatternsUnused.types b/tests/baselines/reference/declarationEmitBindingPatternsUnused.types index 32771df655b98..292ed8b260f86 100644 --- a/tests/baselines/reference/declarationEmitBindingPatternsUnused.types +++ b/tests/baselines/reference/declarationEmitBindingPatternsUnused.types @@ -5,6 +5,42 @@ type Named = { name: string } >Named : { name: string; } >name : string +// Resons we can't remove aliases that are not used in the function signature: + +// 1.Causes duplicate identifier if we remove alias +function duplicateIndetifiers({ name: alias, name: alias2 }: Named) { } +>duplicateIndetifiers : ({ name: alias, name: alias2 }: Named) => void +>name : any +>alias : string +>name : any +>alias2 : string + +function duplicateIndetifiers2(name: string, { name: alias }: Named) { } +>duplicateIndetifiers2 : (name: string, { name: alias }: Named) => void +>name : string +>name : any +>alias : string + +function duplicateIndetifiers3({ name: alias }: Named, { name: alias2 }: Named) { } +>duplicateIndetifiers3 : ({ name: alias }: Named, { name: alias2 }: Named) => void +>name : any +>alias : string +>name : any +>alias2 : string + +let value = ""; +>value : string +>"" : "" + +// 2.Can change in meaning for typeof value if we remove alias +function shadowedVariable({ value: alias }: { value: string }): typeof value { return value } +>shadowedVariable : ({ value: alias }: { value: string;}) => typeof value +>value : any +>alias : string +>value : string +>value : string +>value : string + function notReferenced({ name: alias }: Named) { >notReferenced : ({ name: alias }: Named) => void >name : any @@ -26,8 +62,6 @@ function notReferencedArrayAlias([a, b, { name: alias }]: Named[]) { >alias : string } - - function referencedInCode({ name: alias }: Named) { >referencedInCode : ({ name: alias }: Named) => string >name : any diff --git a/tests/baselines/reference/declarationEmitKeywordDestructuring.js b/tests/baselines/reference/declarationEmitKeywordDestructuring.js index 2f52ebbf5309d..f039acc5c0134 100644 --- a/tests/baselines/reference/declarationEmitKeywordDestructuring.js +++ b/tests/baselines/reference/declarationEmitKeywordDestructuring.js @@ -88,21 +88,21 @@ declare function f2({ function: _function, ...rest }: P): { await: boolean; one: boolean; }; -declare function f3({ abstract, ...rest }: P): { +declare function f3({ abstract: _abstract, ...rest }: P): { enum: boolean; function: boolean; async: boolean; await: boolean; one: boolean; }; -declare function f4({ async, ...rest }: P): { +declare function f4({ async: _async, ...rest }: P): { enum: boolean; function: boolean; abstract: boolean; await: boolean; one: boolean; }; -declare function f5({ await, ...rest }: P): { +declare function f5({ await: _await, ...rest }: P): { enum: boolean; function: boolean; abstract: boolean; diff --git a/tests/baselines/reference/declarationEmitUsingTypeAlias1.js b/tests/baselines/reference/declarationEmitUsingTypeAlias1.js new file mode 100644 index 0000000000000..9bfe2999627b9 --- /dev/null +++ b/tests/baselines/reference/declarationEmitUsingTypeAlias1.js @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/declarationEmitUsingTypeAlias1.ts] //// + +//// [inner.d.ts] +export declare type Other = { other: string }; +export declare type SomeType = { arg: Other }; + +//// [index.d.ts] +export type OtherType = import('./inner').Other; +export type SomeType = import('./inner').SomeType; + +//// [package.json] +{ + "name": "some-dep", + "exports": { + ".": "./dist/index.js" + } +} + +//// [index.ts] +import { SomeType } from "some-dep"; + +export const foo = (thing: SomeType) => { + return thing; +}; + +export const bar = (thing: SomeType) => { + return thing.arg; +}; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bar = exports.foo = void 0; +var foo = function (thing) { + return thing; +}; +exports.foo = foo; +var bar = function (thing) { + return thing.arg; +}; +exports.bar = bar; + + +//// [index.d.ts] +import { SomeType } from "some-dep"; +export declare const foo: (thing: SomeType) => import("some-dep").SomeType; +export declare const bar: (thing: SomeType) => import("some-dep").OtherType; diff --git a/tests/baselines/reference/declarationEmitUsingTypeAlias1.symbols b/tests/baselines/reference/declarationEmitUsingTypeAlias1.symbols new file mode 100644 index 0000000000000..55573f5c9aff2 --- /dev/null +++ b/tests/baselines/reference/declarationEmitUsingTypeAlias1.symbols @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/declarationEmitUsingTypeAlias1.ts] //// + +=== node_modules/some-dep/dist/inner.d.ts === +export declare type Other = { other: string }; +>Other : Symbol(Other, Decl(inner.d.ts, 0, 0)) +>other : Symbol(other, Decl(inner.d.ts, 0, 29)) + +export declare type SomeType = { arg: Other }; +>SomeType : Symbol(SomeType, Decl(inner.d.ts, 0, 46)) +>arg : Symbol(arg, Decl(inner.d.ts, 1, 32)) +>Other : Symbol(Other, Decl(inner.d.ts, 0, 0)) + +=== node_modules/some-dep/dist/index.d.ts === +export type OtherType = import('./inner').Other; +>OtherType : Symbol(OtherType, Decl(index.d.ts, 0, 0)) +>Other : Symbol(Other, Decl(inner.d.ts, 0, 0)) + +export type SomeType = import('./inner').SomeType; +>SomeType : Symbol(SomeType, Decl(index.d.ts, 0, 48)) +>SomeType : Symbol(SomeType, Decl(inner.d.ts, 0, 46)) + +=== src/index.ts === +import { SomeType } from "some-dep"; +>SomeType : Symbol(SomeType, Decl(index.ts, 0, 8)) + +export const foo = (thing: SomeType) => { +>foo : Symbol(foo, Decl(index.ts, 2, 12)) +>thing : Symbol(thing, Decl(index.ts, 2, 20)) +>SomeType : Symbol(SomeType, Decl(index.ts, 0, 8)) + + return thing; +>thing : Symbol(thing, Decl(index.ts, 2, 20)) + +}; + +export const bar = (thing: SomeType) => { +>bar : Symbol(bar, Decl(index.ts, 6, 12)) +>thing : Symbol(thing, Decl(index.ts, 6, 20)) +>SomeType : Symbol(SomeType, Decl(index.ts, 0, 8)) + + return thing.arg; +>thing.arg : Symbol(arg, Decl(inner.d.ts, 1, 32)) +>thing : Symbol(thing, Decl(index.ts, 6, 20)) +>arg : Symbol(arg, Decl(inner.d.ts, 1, 32)) + +}; diff --git a/tests/baselines/reference/declarationEmitUsingTypeAlias1.types b/tests/baselines/reference/declarationEmitUsingTypeAlias1.types new file mode 100644 index 0000000000000..f32f9775eea30 --- /dev/null +++ b/tests/baselines/reference/declarationEmitUsingTypeAlias1.types @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/declarationEmitUsingTypeAlias1.ts] //// + +=== node_modules/some-dep/dist/inner.d.ts === +export declare type Other = { other: string }; +>Other : { other: string; } +>other : string + +export declare type SomeType = { arg: Other }; +>SomeType : { arg: Other; } +>arg : Other + +=== node_modules/some-dep/dist/index.d.ts === +export type OtherType = import('./inner').Other; +>OtherType : import("node_modules/some-dep/dist/inner").Other + +export type SomeType = import('./inner').SomeType; +>SomeType : import("node_modules/some-dep/dist/inner").SomeType + +=== src/index.ts === +import { SomeType } from "some-dep"; +>SomeType : any + +export const foo = (thing: SomeType) => { +>foo : (thing: SomeType) => import("node_modules/some-dep/dist/inner").SomeType +>(thing: SomeType) => { return thing;} : (thing: SomeType) => import("node_modules/some-dep/dist/inner").SomeType +>thing : import("node_modules/some-dep/dist/inner").SomeType + + return thing; +>thing : import("node_modules/some-dep/dist/inner").SomeType + +}; + +export const bar = (thing: SomeType) => { +>bar : (thing: SomeType) => import("node_modules/some-dep/dist/inner").Other +>(thing: SomeType) => { return thing.arg;} : (thing: SomeType) => import("node_modules/some-dep/dist/inner").Other +>thing : import("node_modules/some-dep/dist/inner").SomeType + + return thing.arg; +>thing.arg : import("node_modules/some-dep/dist/inner").Other +>thing : import("node_modules/some-dep/dist/inner").SomeType +>arg : import("node_modules/some-dep/dist/inner").Other + +}; diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types index 72aaa6378e5af..791ba83c243dc 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types @@ -2,16 +2,16 @@ === destructuringArrayBindingPatternAndAssignment3.ts === const [a, b = a] = [1]; // ok ->a : any ->b : any ->a : any +>a : number +>b : number +>a : number >[1] : [number] >1 : 1 const [c, d = c, e = e] = [1]; // error for e = e ->c : any ->d : any ->c : any +>c : number +>d : number +>c : number >e : any >e : any >[1] : [number] diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.js b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.js new file mode 100644 index 0000000000000..47eaab26cd17b --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts] //// + +//// [destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts] +// To be inferred as `number` +function f1() { + const [a1, b1 = a1] = [1]; + const [a2, b2 = 1 + a2] = [1]; +} + +// To be inferred as `string` +function f2() { + const [a1, b1 = a1] = ['hi']; + const [a2, b2 = a2 + '!'] = ['hi']; +} + +// To be inferred as `string | number` +function f3() { + const [a1, b1 = a1] = ['hi', 1]; + const [a2, b2 = a2 + '!'] = ['hi', 1]; +} + +// Based on comment: +// - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 +declare const yadda: [number, number] | undefined +function f4() { + const [ a, b = a ] = yadda ?? []; +} + + +//// [destructuringArrayBindingPatternAndAssignment5SiblingInitializer.js] +// To be inferred as `number` +function f1() { + var _a = [1], a1 = _a[0], _b = _a[1], b1 = _b === void 0 ? a1 : _b; + var _c = [1], a2 = _c[0], _d = _c[1], b2 = _d === void 0 ? 1 + a2 : _d; +} +// To be inferred as `string` +function f2() { + var _a = ['hi'], a1 = _a[0], _b = _a[1], b1 = _b === void 0 ? a1 : _b; + var _c = ['hi'], a2 = _c[0], _d = _c[1], b2 = _d === void 0 ? a2 + '!' : _d; +} +// To be inferred as `string | number` +function f3() { + var _a = ['hi', 1], a1 = _a[0], _b = _a[1], b1 = _b === void 0 ? a1 : _b; + var _c = ['hi', 1], a2 = _c[0], _d = _c[1], b2 = _d === void 0 ? a2 + '!' : _d; +} +function f4() { + var _a = yadda !== null && yadda !== void 0 ? yadda : [], a = _a[0], _b = _a[1], b = _b === void 0 ? a : _b; +} diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.symbols b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.symbols new file mode 100644 index 0000000000000..2ff79c20083f2 --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.symbols @@ -0,0 +1,63 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts] //// + +=== destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts === +// To be inferred as `number` +function f1() { +>f1 : Symbol(f1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 0, 0)) + + const [a1, b1 = a1] = [1]; +>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 2, 11)) +>b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 2, 14)) +>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 2, 11)) + + const [a2, b2 = 1 + a2] = [1]; +>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 3, 11)) +>b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 3, 14)) +>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 3, 11)) +} + +// To be inferred as `string` +function f2() { +>f2 : Symbol(f2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 4, 1)) + + const [a1, b1 = a1] = ['hi']; +>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 8, 11)) +>b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 8, 14)) +>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 8, 11)) + + const [a2, b2 = a2 + '!'] = ['hi']; +>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 9, 11)) +>b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 9, 14)) +>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 9, 11)) +} + +// To be inferred as `string | number` +function f3() { +>f3 : Symbol(f3, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 10, 1)) + + const [a1, b1 = a1] = ['hi', 1]; +>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 14, 11)) +>b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 14, 14)) +>a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 14, 11)) + + const [a2, b2 = a2 + '!'] = ['hi', 1]; +>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 15, 11)) +>b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 15, 14)) +>a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 15, 11)) +} + +// Based on comment: +// - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 +declare const yadda: [number, number] | undefined +>yadda : Symbol(yadda, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 20, 13)) + +function f4() { +>f4 : Symbol(f4, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 20, 49)) + + const [ a, b = a ] = yadda ?? []; +>a : Symbol(a, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 22, 11)) +>b : Symbol(b, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 22, 14)) +>a : Symbol(a, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 22, 11)) +>yadda : Symbol(yadda, Decl(destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts, 20, 13)) +} + diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types new file mode 100644 index 0000000000000..009a62ee2d987 --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types @@ -0,0 +1,85 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts] //// + +=== destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts === +// To be inferred as `number` +function f1() { +>f1 : () => void + + const [a1, b1 = a1] = [1]; +>a1 : number +>b1 : number +>a1 : number +>[1] : [number] +>1 : 1 + + const [a2, b2 = 1 + a2] = [1]; +>a2 : number +>b2 : number +>1 + a2 : number +>1 : 1 +>a2 : number +>[1] : [number] +>1 : 1 +} + +// To be inferred as `string` +function f2() { +>f2 : () => void + + const [a1, b1 = a1] = ['hi']; +>a1 : string +>b1 : string +>a1 : string +>['hi'] : [string] +>'hi' : "hi" + + const [a2, b2 = a2 + '!'] = ['hi']; +>a2 : string +>b2 : string +>a2 + '!' : string +>a2 : string +>'!' : "!" +>['hi'] : [string] +>'hi' : "hi" +} + +// To be inferred as `string | number` +function f3() { +>f3 : () => void + + const [a1, b1 = a1] = ['hi', 1]; +>a1 : string +>b1 : string | number +>a1 : string +>['hi', 1] : [string, number] +>'hi' : "hi" +>1 : 1 + + const [a2, b2 = a2 + '!'] = ['hi', 1]; +>a2 : string +>b2 : string | number +>a2 + '!' : string +>a2 : string +>'!' : "!" +>['hi', 1] : [string, number] +>'hi' : "hi" +>1 : 1 +} + +// Based on comment: +// - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 +declare const yadda: [number, number] | undefined +>yadda : [number, number] + +function f4() { +>f4 : () => void + + const [ a, b = a ] = yadda ?? []; +>a : number +>b : number +>a : number +>yadda ?? [] : [number, number] | [] +>yadda : [number, number] +>[] : [] +} + diff --git a/tests/baselines/reference/destructuringInFunctionType.js b/tests/baselines/reference/destructuringInFunctionType.js index e03a8fc5c4e93..bd444d850f382 100644 --- a/tests/baselines/reference/destructuringInFunctionType.js +++ b/tests/baselines/reference/destructuringInFunctionType.js @@ -54,7 +54,7 @@ type T3 = ([{ }, { b: a; }]); -type F3 = ([{ a }, { b }]: [{ +type F3 = ([{ a: b }, { b: a }]: [{ a: any; }, { b: any; diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.js new file mode 100644 index 0000000000000..92a7a56842bfc --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts] //// + +//// [destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts] +// To be inferred as `number` +function f1() { + const { a1, b1 = a1 } = { a1: 1 }; + const { a2, b2 = 1 + a2 } = { a2: 1 }; +} + +// To be inferred as `string` +function f2() { + const { a1, b1 = a1 } = { a1: 'hi' }; + const { a2, b2 = a2 + '!' } = { a2: 'hi' }; +} + +// To be inferred as `string | number` +function f3() { + const { a1, b1 = a1 } = { a1: 'hi', b1: 1 }; + const { a2, b2 = a2 + '!' } = { a2: 'hi', b2: 1 }; +} + +// Based on comment: +// - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 +declare const yadda: { a?: number, b?: number } | undefined +function f4() { + const { a, b = a } = yadda ?? {}; +} + + +//// [destructuringObjectBindingPatternAndAssignment9SiblingInitializer.js] +// To be inferred as `number` +function f1() { + var _a = { a1: 1 }, a1 = _a.a1, _b = _a.b1, b1 = _b === void 0 ? a1 : _b; + var _c = { a2: 1 }, a2 = _c.a2, _d = _c.b2, b2 = _d === void 0 ? 1 + a2 : _d; +} +// To be inferred as `string` +function f2() { + var _a = { a1: 'hi' }, a1 = _a.a1, _b = _a.b1, b1 = _b === void 0 ? a1 : _b; + var _c = { a2: 'hi' }, a2 = _c.a2, _d = _c.b2, b2 = _d === void 0 ? a2 + '!' : _d; +} +// To be inferred as `string | number` +function f3() { + var _a = { a1: 'hi', b1: 1 }, a1 = _a.a1, _b = _a.b1, b1 = _b === void 0 ? a1 : _b; + var _c = { a2: 'hi', b2: 1 }, a2 = _c.a2, _d = _c.b2, b2 = _d === void 0 ? a2 + '!' : _d; +} +function f4() { + var _a = yadda !== null && yadda !== void 0 ? yadda : {}, a = _a.a, _b = _a.b, b = _b === void 0 ? a : _b; +} diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.symbols b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.symbols new file mode 100644 index 0000000000000..3c76a5d2b045d --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.symbols @@ -0,0 +1,73 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts] //// + +=== destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts === +// To be inferred as `number` +function f1() { +>f1 : Symbol(f1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 0, 0)) + + const { a1, b1 = a1 } = { a1: 1 }; +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 2, 11)) +>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 2, 15)) +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 2, 11)) +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 2, 29)) + + const { a2, b2 = 1 + a2 } = { a2: 1 }; +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 3, 11)) +>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 3, 15)) +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 3, 11)) +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 3, 33)) +} + +// To be inferred as `string` +function f2() { +>f2 : Symbol(f2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 4, 1)) + + const { a1, b1 = a1 } = { a1: 'hi' }; +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 8, 11)) +>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 8, 15)) +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 8, 11)) +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 8, 29)) + + const { a2, b2 = a2 + '!' } = { a2: 'hi' }; +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 9, 11)) +>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 9, 15)) +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 9, 11)) +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 9, 35)) +} + +// To be inferred as `string | number` +function f3() { +>f3 : Symbol(f3, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 10, 1)) + + const { a1, b1 = a1 } = { a1: 'hi', b1: 1 }; +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 14, 11)) +>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 14, 15)) +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 14, 11)) +>a1 : Symbol(a1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 14, 29)) +>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 14, 39)) + + const { a2, b2 = a2 + '!' } = { a2: 'hi', b2: 1 }; +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 15, 11)) +>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 15, 15)) +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 15, 11)) +>a2 : Symbol(a2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 15, 35)) +>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 15, 45)) +} + +// Based on comment: +// - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 +declare const yadda: { a?: number, b?: number } | undefined +>yadda : Symbol(yadda, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 20, 13)) +>a : Symbol(a, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 20, 22)) +>b : Symbol(b, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 20, 34)) + +function f4() { +>f4 : Symbol(f4, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 20, 59)) + + const { a, b = a } = yadda ?? {}; +>a : Symbol(a, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 22, 11)) +>b : Symbol(b, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 22, 14)) +>a : Symbol(a, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 22, 11)) +>yadda : Symbol(yadda, Decl(destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts, 20, 13)) +} + diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types new file mode 100644 index 0000000000000..c5ebaabe82453 --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types @@ -0,0 +1,95 @@ +//// [tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts] //// + +=== destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts === +// To be inferred as `number` +function f1() { +>f1 : () => void + + const { a1, b1 = a1 } = { a1: 1 }; +>a1 : number +>b1 : number +>a1 : number +>{ a1: 1 } : { a1: number; b1?: number; } +>a1 : number +>1 : 1 + + const { a2, b2 = 1 + a2 } = { a2: 1 }; +>a2 : number +>b2 : number +>1 + a2 : number +>1 : 1 +>a2 : number +>{ a2: 1 } : { a2: number; b2?: number; } +>a2 : number +>1 : 1 +} + +// To be inferred as `string` +function f2() { +>f2 : () => void + + const { a1, b1 = a1 } = { a1: 'hi' }; +>a1 : string +>b1 : string +>a1 : string +>{ a1: 'hi' } : { a1: string; b1?: string; } +>a1 : string +>'hi' : "hi" + + const { a2, b2 = a2 + '!' } = { a2: 'hi' }; +>a2 : string +>b2 : string +>a2 + '!' : string +>a2 : string +>'!' : "!" +>{ a2: 'hi' } : { a2: string; b2?: string; } +>a2 : string +>'hi' : "hi" +} + +// To be inferred as `string | number` +function f3() { +>f3 : () => void + + const { a1, b1 = a1 } = { a1: 'hi', b1: 1 }; +>a1 : string +>b1 : string | number +>a1 : string +>{ a1: 'hi', b1: 1 } : { a1: string; b1?: number; } +>a1 : string +>'hi' : "hi" +>b1 : number +>1 : 1 + + const { a2, b2 = a2 + '!' } = { a2: 'hi', b2: 1 }; +>a2 : string +>b2 : string | number +>a2 + '!' : string +>a2 : string +>'!' : "!" +>{ a2: 'hi', b2: 1 } : { a2: string; b2?: number; } +>a2 : string +>'hi' : "hi" +>b2 : number +>1 : 1 +} + +// Based on comment: +// - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 +declare const yadda: { a?: number, b?: number } | undefined +>yadda : { a?: number; b?: number; } +>a : number +>b : number + +function f4() { +>f4 : () => void + + const { a, b = a } = yadda ?? {}; +>a : number +>b : number +>a : number +>yadda ?? {} : { a?: number; b?: number; } +>yadda : { a?: number; b?: number; } +>{} : {} +} + diff --git a/tests/baselines/reference/goToDefinitionSwitchCase1.baseline.jsonc b/tests/baselines/reference/goToDefinitionSwitchCase1.baseline.jsonc new file mode 100644 index 0000000000000..c92107111f2a0 --- /dev/null +++ b/tests/baselines/reference/goToDefinitionSwitchCase1.baseline.jsonc @@ -0,0 +1,17 @@ +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase1.ts === +// <|[|switch|] (null )|> { +// /*GOTO DEF*/case null: break; +// } + + // === Details === + [ + { + "kind": "keyword", + "name": "switch", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/goToDefinitionSwitchCase2.baseline.jsonc b/tests/baselines/reference/goToDefinitionSwitchCase2.baseline.jsonc new file mode 100644 index 0000000000000..318e346d9398f --- /dev/null +++ b/tests/baselines/reference/goToDefinitionSwitchCase2.baseline.jsonc @@ -0,0 +1,17 @@ +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase2.ts === +// <|[|switch|] (null)|> { +// /*GOTO DEF*/default: break; +// } + + // === Details === + [ + { + "kind": "keyword", + "name": "switch", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/goToDefinitionSwitchCase3.baseline.jsonc b/tests/baselines/reference/goToDefinitionSwitchCase3.baseline.jsonc new file mode 100644 index 0000000000000..022a654b71cdd --- /dev/null +++ b/tests/baselines/reference/goToDefinitionSwitchCase3.baseline.jsonc @@ -0,0 +1,45 @@ +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase3.ts === +// <|[|switch|] (null)|> { +// /*GOTO DEF*/default: { +// switch (null) { +// default: break; +// } +// }; +// } + + // === Details === + [ + { + "kind": "keyword", + "name": "switch", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] + + + +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase3.ts === +// switch (null) { +// default: { +// <|[|switch|] (null)|> { +// /*GOTO DEF*/default: break; +// } +// }; +// } + + // === Details === + [ + { + "kind": "keyword", + "name": "switch", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/goToDefinitionSwitchCase4.baseline.jsonc b/tests/baselines/reference/goToDefinitionSwitchCase4.baseline.jsonc new file mode 100644 index 0000000000000..12b7b46563064 --- /dev/null +++ b/tests/baselines/reference/goToDefinitionSwitchCase4.baseline.jsonc @@ -0,0 +1,21 @@ +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase4.ts === +// switch (null) { +// case null: break; +// } +// +// <|[|switch|] (null)|> { +// /*GOTO DEF*/case null: break; +// } + + // === Details === + [ + { + "kind": "keyword", + "name": "switch", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/goToDefinitionSwitchCase5.baseline.jsonc b/tests/baselines/reference/goToDefinitionSwitchCase5.baseline.jsonc new file mode 100644 index 0000000000000..1277d0b5dd945 --- /dev/null +++ b/tests/baselines/reference/goToDefinitionSwitchCase5.baseline.jsonc @@ -0,0 +1,16 @@ +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase5.ts === +// [|export /*GOTO DEF*/default {}|] + + // === Details === + [ + { + "kind": "property", + "name": "default", + "containerName": "\"/tests/cases/fourslash/goToDefinitionSwitchCase5\"", + "isLocal": true, + "isAmbient": false, + "unverified": false, + "failedAliasResolution": false + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/goToDefinitionSwitchCase6.baseline.jsonc b/tests/baselines/reference/goToDefinitionSwitchCase6.baseline.jsonc new file mode 100644 index 0000000000000..3f6894203dc69 --- /dev/null +++ b/tests/baselines/reference/goToDefinitionSwitchCase6.baseline.jsonc @@ -0,0 +1,47 @@ +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase6.ts === +// export default { /*GOTO DEF*/[|{| textSpan: true |}case|] }; +// default; +// case 42; + + // === Details === + [ + { + "kind": "property", + "name": "case", + "containerName": "__object", + "isLocal": true, + "isAmbient": false, + "unverified": false, + "failedAliasResolution": false + } + ] + + + +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase6.ts === +// [|export default { case }; +// /*GOTO DEF*/default; +// case 42;|] + + // === Details === + [ + { + "kind": "module", + "name": "\"/tests/cases/fourslash/goToDefinitionSwitchCase6\"", + "containerName": "", + "isLocal": false, + "isAmbient": false, + "unverified": false, + "failedAliasResolution": false + } + ] + + + +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase6.ts === +// export default { case }; +// default; +// /*GOTO DEF*/case 42; \ No newline at end of file diff --git a/tests/baselines/reference/goToDefinitionSwitchCase7.baseline.jsonc b/tests/baselines/reference/goToDefinitionSwitchCase7.baseline.jsonc new file mode 100644 index 0000000000000..bf6c818dc552e --- /dev/null +++ b/tests/baselines/reference/goToDefinitionSwitchCase7.baseline.jsonc @@ -0,0 +1,18 @@ +// === goToDefinition === +// === /tests/cases/fourslash/goToDefinitionSwitchCase7.ts === +// switch (null) { +// case null: +// [|export /*GOTO DEF*/default 123;|] + + // === Details === + [ + { + "kind": "var", + "name": "default", + "containerName": "", + "isLocal": true, + "isAmbient": false, + "unverified": false, + "failedAliasResolution": false + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/importAssertionNonstring.errors.txt b/tests/baselines/reference/importAssertionNonstring.errors.txt index bb55e2a13bc1d..81a06f278084d 100644 --- a/tests/baselines/reference/importAssertionNonstring.errors.txt +++ b/tests/baselines/reference/importAssertionNonstring.errors.txt @@ -1,13 +1,29 @@ +mod.mts(1,37): error TS2322: Type '{ field: 0; }' is not assignable to type 'ImportAttributes'. + Property 'field' is incompatible with index signature. + Type 'number' is not assignable to type 'string'. mod.mts(1,52): error TS2837: Import assertion values must be string literal expressions. mod.mts(3,52): error TS2837: Import assertion values must be string literal expressions. +mod.mts(5,37): error TS2322: Type '{ field: RegExp; }' is not assignable to type 'ImportAttributes'. + Property 'field' is incompatible with index signature. + Type 'RegExp' is not assignable to type 'string'. mod.mts(5,52): error TS2837: Import assertion values must be string literal expressions. +mod.mts(7,37): error TS2322: Type '{ field: string[]; }' is not assignable to type 'ImportAttributes'. + Property 'field' is incompatible with index signature. + Type 'string[]' is not assignable to type 'string'. mod.mts(7,52): error TS2837: Import assertion values must be string literal expressions. +mod.mts(9,37): error TS2322: Type '{ field: { a: number; }; }' is not assignable to type 'ImportAttributes'. + Property 'field' is incompatible with index signature. + Type '{ a: number; }' is not assignable to type 'string'. mod.mts(9,52): error TS2837: Import assertion values must be string literal expressions. mod.mts(11,66): error TS2837: Import assertion values must be string literal expressions. -==== mod.mts (6 errors) ==== +==== mod.mts (10 errors) ==== import * as thing1 from "./mod.mjs" assert {field: 0}; + ~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ field: 0; }' is not assignable to type 'ImportAttributes'. +!!! error TS2322: Property 'field' is incompatible with index signature. +!!! error TS2322: Type 'number' is not assignable to type 'string'. ~ !!! error TS2837: Import assertion values must be string literal expressions. @@ -16,14 +32,26 @@ mod.mts(11,66): error TS2837: Import assertion values must be string literal exp !!! error TS2837: Import assertion values must be string literal expressions. import * as thing3 from "./mod.mjs" assert {field: /a/g}; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ field: RegExp; }' is not assignable to type 'ImportAttributes'. +!!! error TS2322: Property 'field' is incompatible with index signature. +!!! error TS2322: Type 'RegExp' is not assignable to type 'string'. ~~~~ !!! error TS2837: Import assertion values must be string literal expressions. import * as thing4 from "./mod.mjs" assert {field: ["a"]}; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ field: string[]; }' is not assignable to type 'ImportAttributes'. +!!! error TS2322: Property 'field' is incompatible with index signature. +!!! error TS2322: Type 'string[]' is not assignable to type 'string'. ~~~~~ !!! error TS2837: Import assertion values must be string literal expressions. import * as thing5 from "./mod.mjs" assert {field: { a: 0 }}; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ field: { a: number; }; }' is not assignable to type 'ImportAttributes'. +!!! error TS2322: Property 'field' is incompatible with index signature. +!!! error TS2322: Type '{ a: number; }' is not assignable to type 'string'. ~~~~~~~~ !!! error TS2837: Import assertion values must be string literal expressions. diff --git a/tests/baselines/reference/importAttributes6.errors.txt b/tests/baselines/reference/importAttributes6.errors.txt index 18fa0ba6b693d..f2f160a4bd0e1 100644 --- a/tests/baselines/reference/importAttributes6.errors.txt +++ b/tests/baselines/reference/importAttributes6.errors.txt @@ -1,25 +1,53 @@ +mod.mts(1,37): error TS2322: Type '{ field: 0; }' is not assignable to type 'ImportAttributes'. + Property 'field' is incompatible with index signature. + Type 'number' is not assignable to type 'string'. mod.mts(1,51): error TS2858: Import attribute values must be string literal expressions. mod.mts(2,51): error TS2858: Import attribute values must be string literal expressions. +mod.mts(3,37): error TS2322: Type '{ field: RegExp; }' is not assignable to type 'ImportAttributes'. + Property 'field' is incompatible with index signature. + Type 'RegExp' is not assignable to type 'string'. mod.mts(3,51): error TS2858: Import attribute values must be string literal expressions. +mod.mts(4,37): error TS2322: Type '{ field: string[]; }' is not assignable to type 'ImportAttributes'. + Property 'field' is incompatible with index signature. + Type 'string[]' is not assignable to type 'string'. mod.mts(4,51): error TS2858: Import attribute values must be string literal expressions. +mod.mts(5,37): error TS2322: Type '{ field: { a: number; }; }' is not assignable to type 'ImportAttributes'. + Property 'field' is incompatible with index signature. + Type '{ a: number; }' is not assignable to type 'string'. mod.mts(5,51): error TS2858: Import attribute values must be string literal expressions. mod.mts(6,65): error TS2858: Import attribute values must be string literal expressions. -==== mod.mts (6 errors) ==== +==== mod.mts (10 errors) ==== import * as thing1 from "./mod.mjs" with { field: 0 }; + ~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ field: 0; }' is not assignable to type 'ImportAttributes'. +!!! error TS2322: Property 'field' is incompatible with index signature. +!!! error TS2322: Type 'number' is not assignable to type 'string'. ~ !!! error TS2858: Import attribute values must be string literal expressions. import * as thing2 from "./mod.mjs" with { field: `a` }; ~~~ !!! error TS2858: Import attribute values must be string literal expressions. import * as thing3 from "./mod.mjs" with { field: /a/g }; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ field: RegExp; }' is not assignable to type 'ImportAttributes'. +!!! error TS2322: Property 'field' is incompatible with index signature. +!!! error TS2322: Type 'RegExp' is not assignable to type 'string'. ~~~~ !!! error TS2858: Import attribute values must be string literal expressions. import * as thing4 from "./mod.mjs" with { field: ["a"] }; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ field: string[]; }' is not assignable to type 'ImportAttributes'. +!!! error TS2322: Property 'field' is incompatible with index signature. +!!! error TS2322: Type 'string[]' is not assignable to type 'string'. ~~~~~ !!! error TS2858: Import attribute values must be string literal expressions. import * as thing5 from "./mod.mjs" with { field: { a: 0 } }; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ field: { a: number; }; }' is not assignable to type 'ImportAttributes'. +!!! error TS2322: Property 'field' is incompatible with index signature. +!!! error TS2322: Type '{ a: number; }' is not assignable to type 'string'. ~~~~~~~~ !!! error TS2858: Import attribute values must be string literal expressions. import * as thing6 from "./mod.mjs" with { type: "json", field: 0..toString() }; diff --git a/tests/baselines/reference/importAttributes9.errors.txt b/tests/baselines/reference/importAttributes9.errors.txt new file mode 100644 index 0000000000000..59006e6b71ed8 --- /dev/null +++ b/tests/baselines/reference/importAttributes9.errors.txt @@ -0,0 +1,41 @@ +b.ts(7,27): error TS2322: Type '{ type: "not-json"; }' is not assignable to type 'ImportAttributes'. + Types of property 'type' are incompatible. + Type '"not-json"' is not assignable to type '"json"'. +b.ts(11,25): error TS2322: Type '{ with: { type: "not-json"; }; }' is not assignable to type 'ImportCallOptions'. + The types of 'with.type' are incompatible between these types. + Type '"not-json"' is not assignable to type '"json"'. + + +==== ./a.ts (0 errors) ==== + export default {}; + +==== ./b.ts (2 errors) ==== + declare global { + interface ImportAttributes { + type: "json" + } + } + + import * as ns from "./a" with { type: "not-json" }; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ type: "not-json"; }' is not assignable to type 'ImportAttributes'. +!!! error TS2322: Types of property 'type' are incompatible. +!!! error TS2322: Type '"not-json"' is not assignable to type '"json"'. + void ns; + + async function f() { + await import("./a", { + ~ + with: { + ~~~~~~~~~~~~~~~ + type: "not-json", + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }, + ~~~~~~~~~~ + }); + ~~~~~ +!!! error TS2322: Type '{ with: { type: "not-json"; }; }' is not assignable to type 'ImportCallOptions'. +!!! error TS2322: The types of 'with.type' are incompatible between these types. +!!! error TS2322: Type '"not-json"' is not assignable to type '"json"'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/importAttributes9.js b/tests/baselines/reference/importAttributes9.js new file mode 100644 index 0000000000000..10e5230e2b697 --- /dev/null +++ b/tests/baselines/reference/importAttributes9.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/importAttributes/importAttributes9.ts] //// + +//// [a.ts] +export default {}; + +//// [b.ts] +declare global { + interface ImportAttributes { + type: "json" + } +} + +import * as ns from "./a" with { type: "not-json" }; +void ns; + +async function f() { + await import("./a", { + with: { + type: "not-json", + }, + }); +} + + +//// [a.js] +export default {}; +//// [b.js] +import * as ns from "./a" with { type: "not-json" }; +void ns; +async function f() { + await import("./a", { + with: { + type: "not-json", + }, + }); +} diff --git a/tests/baselines/reference/importAttributes9.symbols b/tests/baselines/reference/importAttributes9.symbols new file mode 100644 index 0000000000000..bb0975afa8dc0 --- /dev/null +++ b/tests/baselines/reference/importAttributes9.symbols @@ -0,0 +1,40 @@ +//// [tests/cases/conformance/importAttributes/importAttributes9.ts] //// + +=== ./a.ts === + +export default {}; + +=== ./b.ts === +declare global { +>global : Symbol(global, Decl(b.ts, 0, 0)) + + interface ImportAttributes { +>ImportAttributes : Symbol(ImportAttributes, Decl(lib.es5.d.ts, --, --), Decl(b.ts, 0, 16)) + + type: "json" +>type : Symbol(ImportAttributes.type, Decl(b.ts, 1, 33)) + } +} + +import * as ns from "./a" with { type: "not-json" }; +>ns : Symbol(ns, Decl(b.ts, 6, 6)) + +void ns; +>ns : Symbol(ns, Decl(b.ts, 6, 6)) + +async function f() { +>f : Symbol(f, Decl(b.ts, 7, 8)) + + await import("./a", { +>"./a" : Symbol(ns, Decl(a.ts, 0, 0)) + + with: { +>with : Symbol(with, Decl(b.ts, 10, 25)) + + type: "not-json", +>type : Symbol(type, Decl(b.ts, 11, 15)) + + }, + }); +} + diff --git a/tests/baselines/reference/importAttributes9.types b/tests/baselines/reference/importAttributes9.types new file mode 100644 index 0000000000000..c17e4150005ec --- /dev/null +++ b/tests/baselines/reference/importAttributes9.types @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/importAttributes/importAttributes9.ts] //// + +=== ./a.ts === +export default {}; +>{} : {} + +=== ./b.ts === +declare global { +>global : any + + interface ImportAttributes { + type: "json" +>type : "json" + } +} + +import * as ns from "./a" with { type: "not-json" }; +>ns : typeof ns +>type : any + +void ns; +>void ns : undefined +>ns : typeof ns + +async function f() { +>f : () => Promise + + await import("./a", { +>await import("./a", { with: { type: "not-json", }, }) : typeof ns +>import("./a", { with: { type: "not-json", }, }) : Promise +>"./a" : "./a" +>{ with: { type: "not-json", }, } : { with: { type: "not-json"; }; } + + with: { +>with : { type: "not-json"; } +>{ type: "not-json", } : { type: "not-json"; } + + type: "not-json", +>type : "not-json" +>"not-json" : "not-json" + + }, + }); +} + diff --git a/tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js b/tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js new file mode 100644 index 0000000000000..1e02c358656d6 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts] //// + +//// [index.js] +/** + * @typedef Options + * @property {string} opt + */ + +/** + * @param {Options} options + */ +module.exports = function loader(options) {} + + +//// [index.js] +"use strict"; +/** + * @typedef Options + * @property {string} opt + */ +/** + * @param {Options} options + */ +module.exports = function loader(options) { }; + + +//// [index.d.ts] +declare namespace _exports { + export { Options }; +} +declare function _exports(options: Options): void; +export = _exports; +type Options = { + opt: string; +}; diff --git a/tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols b/tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols new file mode 100644 index 0000000000000..dc72dbfb0b17d --- /dev/null +++ b/tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts] //// + +=== index.js === +/** + * @typedef Options + * @property {string} opt + */ + +/** + * @param {Options} options + */ +module.exports = function loader(options) {} +>module.exports : Symbol(module.exports, Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 0, 0)) +>exports : Symbol(export=, Decl(index.js, 0, 0)) +>loader : Symbol(loader, Decl(index.js, 8, 16)) +>options : Symbol(options, Decl(index.js, 8, 33)) + diff --git a/tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types b/tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types new file mode 100644 index 0000000000000..4343d7b088e5b --- /dev/null +++ b/tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts] //// + +=== index.js === +/** + * @typedef Options + * @property {string} opt + */ + +/** + * @param {Options} options + */ +module.exports = function loader(options) {} +>module.exports = function loader(options) {} : (options: Options) => void +>module.exports : (options: Options) => void +>module : { exports: (options: Options) => void; } +>exports : (options: Options) => void +>function loader(options) {} : (options: Options) => void +>loader : (options: Options) => void +>options : Options + diff --git a/tests/baselines/reference/mapGroupBy.js b/tests/baselines/reference/mapGroupBy.js new file mode 100644 index 0000000000000..497f555fd0120 --- /dev/null +++ b/tests/baselines/reference/mapGroupBy.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/mapGroupBy.ts] //// + +//// [mapGroupBy.ts] +const basic = Map.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); + +const chars = Map.groupBy('a string', c => c); + +type Employee = { name: string, role: 'ic' | 'manager' } +const employees: Set = new Set(); +const byRole = Map.groupBy(employees, x => x.role); + +const byNonKey = Map.groupBy(employees, x => x); + + +//// [mapGroupBy.js] +const basic = Map.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); +const chars = Map.groupBy('a string', c => c); +const employees = new Set(); +const byRole = Map.groupBy(employees, x => x.role); +const byNonKey = Map.groupBy(employees, x => x); diff --git a/tests/baselines/reference/mapGroupBy.symbols b/tests/baselines/reference/mapGroupBy.symbols new file mode 100644 index 0000000000000..4905d158fc9d8 --- /dev/null +++ b/tests/baselines/reference/mapGroupBy.symbols @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/mapGroupBy.ts] //// + +=== mapGroupBy.ts === +const basic = Map.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); +>basic : Symbol(basic, Decl(mapGroupBy.ts, 0, 5)) +>Map.groupBy : Symbol(MapConstructor.groupBy, Decl(lib.esnext.collection.d.ts, --, --)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>groupBy : Symbol(MapConstructor.groupBy, Decl(lib.esnext.collection.d.ts, --, --)) +>x : Symbol(x, Decl(mapGroupBy.ts, 0, 36)) +>x : Symbol(x, Decl(mapGroupBy.ts, 0, 36)) + +const chars = Map.groupBy('a string', c => c); +>chars : Symbol(chars, Decl(mapGroupBy.ts, 2, 5)) +>Map.groupBy : Symbol(MapConstructor.groupBy, Decl(lib.esnext.collection.d.ts, --, --)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>groupBy : Symbol(MapConstructor.groupBy, Decl(lib.esnext.collection.d.ts, --, --)) +>c : Symbol(c, Decl(mapGroupBy.ts, 2, 37)) +>c : Symbol(c, Decl(mapGroupBy.ts, 2, 37)) + +type Employee = { name: string, role: 'ic' | 'manager' } +>Employee : Symbol(Employee, Decl(mapGroupBy.ts, 2, 46)) +>name : Symbol(name, Decl(mapGroupBy.ts, 4, 17)) +>role : Symbol(role, Decl(mapGroupBy.ts, 4, 31)) + +const employees: Set = new Set(); +>employees : Symbol(employees, Decl(mapGroupBy.ts, 5, 5)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>Employee : Symbol(Employee, Decl(mapGroupBy.ts, 2, 46)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +const byRole = Map.groupBy(employees, x => x.role); +>byRole : Symbol(byRole, Decl(mapGroupBy.ts, 6, 5)) +>Map.groupBy : Symbol(MapConstructor.groupBy, Decl(lib.esnext.collection.d.ts, --, --)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>groupBy : Symbol(MapConstructor.groupBy, Decl(lib.esnext.collection.d.ts, --, --)) +>employees : Symbol(employees, Decl(mapGroupBy.ts, 5, 5)) +>x : Symbol(x, Decl(mapGroupBy.ts, 6, 37)) +>x.role : Symbol(role, Decl(mapGroupBy.ts, 4, 31)) +>x : Symbol(x, Decl(mapGroupBy.ts, 6, 37)) +>role : Symbol(role, Decl(mapGroupBy.ts, 4, 31)) + +const byNonKey = Map.groupBy(employees, x => x); +>byNonKey : Symbol(byNonKey, Decl(mapGroupBy.ts, 8, 5)) +>Map.groupBy : Symbol(MapConstructor.groupBy, Decl(lib.esnext.collection.d.ts, --, --)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>groupBy : Symbol(MapConstructor.groupBy, Decl(lib.esnext.collection.d.ts, --, --)) +>employees : Symbol(employees, Decl(mapGroupBy.ts, 5, 5)) +>x : Symbol(x, Decl(mapGroupBy.ts, 8, 39)) +>x : Symbol(x, Decl(mapGroupBy.ts, 8, 39)) + diff --git a/tests/baselines/reference/mapGroupBy.types b/tests/baselines/reference/mapGroupBy.types new file mode 100644 index 0000000000000..998b2254156f1 --- /dev/null +++ b/tests/baselines/reference/mapGroupBy.types @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/mapGroupBy.ts] //// + +=== mapGroupBy.ts === +const basic = Map.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); +>basic : Map<"small" | "large", number[]> +>Map.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large') : Map<"small" | "large", number[]> +>Map.groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Map +>Map : MapConstructor +>groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Map +>[0, 2, 8] : number[] +>0 : 0 +>2 : 2 +>8 : 8 +>x => x < 5 ? 'small' : 'large' : (x: number) => "small" | "large" +>x : number +>x < 5 ? 'small' : 'large' : "small" | "large" +>x < 5 : boolean +>x : number +>5 : 5 +>'small' : "small" +>'large' : "large" + +const chars = Map.groupBy('a string', c => c); +>chars : Map +>Map.groupBy('a string', c => c) : Map +>Map.groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Map +>Map : MapConstructor +>groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Map +>'a string' : "a string" +>c => c : (c: string) => string +>c : string +>c : string + +type Employee = { name: string, role: 'ic' | 'manager' } +>Employee : { name: string; role: 'ic' | 'manager'; } +>name : string +>role : "ic" | "manager" + +const employees: Set = new Set(); +>employees : Set +>new Set() : Set +>Set : SetConstructor + +const byRole = Map.groupBy(employees, x => x.role); +>byRole : Map<"ic" | "manager", Employee[]> +>Map.groupBy(employees, x => x.role) : Map<"ic" | "manager", Employee[]> +>Map.groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Map +>Map : MapConstructor +>groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Map +>employees : Set +>x => x.role : (x: Employee) => "ic" | "manager" +>x : Employee +>x.role : "ic" | "manager" +>x : Employee +>role : "ic" | "manager" + +const byNonKey = Map.groupBy(employees, x => x); +>byNonKey : Map +>Map.groupBy(employees, x => x) : Map +>Map.groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Map +>Map : MapConstructor +>groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Map +>employees : Set +>x => x : (x: Employee) => Employee +>x : Employee +>x : Employee + diff --git a/tests/baselines/reference/noInfer.errors.txt b/tests/baselines/reference/noInfer.errors.txt new file mode 100644 index 0000000000000..2b016511a09b2 --- /dev/null +++ b/tests/baselines/reference/noInfer.errors.txt @@ -0,0 +1,125 @@ +noInfer.ts(35,13): error TS2345: Argument of type '"bar"' is not assignable to parameter of type '"foo"'. +noInfer.ts(36,14): error TS2322: Type '"bar"' is not assignable to type '"foo"'. +noInfer.ts(37,14): error TS2322: Type '"bar"' is not assignable to type '"foo"'. +noInfer.ts(38,15): error TS2322: Type '"bar"' is not assignable to type '"foo"'. +noInfer.ts(39,15): error TS2322: Type '"bar"' is not assignable to type '"foo"'. +noInfer.ts(47,30): error TS2741: Property 'woof' is missing in type 'Animal' but required in type 'Dog'. +noInfer.ts(53,16): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type '{ x: number; y: number; }'. + Property 'y' is missing in type '{ x: number; }' but required in type '{ x: number; y: number; }'. +noInfer.ts(58,22): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. +noInfer.ts(59,14): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. +noInfer.ts(66,14): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ foo: number; }'. + Property 'foo' is missing in type '{}' but required in type '{ foo: number; }'. + + +==== noInfer.ts (10 errors) ==== + // NoInfer is erased for primitives + + type T00 = NoInfer; + type T01 = NoInfer; + type T02 = NoInfer; + type T03 = NoInfer<"foo">; + type T04 = NoInfer<`foo${string}`>; + type T05 = NoInfer<`foo${string}` & `${string}bar`>; + type T06 = NoInfer<{}>; + + // NoInfer is preserved for object types + + type T10 = NoInfer; + type T11 = NoInfer<{ x: string }>; + + // NoInfer is erased if it has no effect + + type T20 = NoInfer>; + type T21 = NoInfer & string>; + type T22 = NoInfer & string[]>; + + // keyof NoInfer is transformed into NoInfer + + type T30 = keyof NoInfer<{ a: string, b: string }>; + type T31 = keyof NoInfer; + type T32 = { [K in keyof NoInfer<{ a: string, b: string }>]: K }; + + declare function foo1(a: T, b: NoInfer): void + declare function foo2(a: T, b: NoInfer[]): void + declare function foo3(a: T, b: NoInfer): void + declare function foo4(a: T, b: { x: NoInfer }): void + declare function foo5(a: T, b: NoInfer<{ x: T }>): void + + foo1('foo', 'foo') // ok + foo1('foo', 'bar') // error + ~~~~~ +!!! error TS2345: Argument of type '"bar"' is not assignable to parameter of type '"foo"'. + foo2('foo', ['bar']) // error + ~~~~~ +!!! error TS2322: Type '"bar"' is not assignable to type '"foo"'. + foo3('foo', ['bar']) // error + ~~~~~ +!!! error TS2322: Type '"bar"' is not assignable to type '"foo"'. + foo4('foo', { x: 'bar' }) // error + ~ +!!! error TS2322: Type '"bar"' is not assignable to type '"foo"'. +!!! related TS6500 noInfer.ts:31:52: The expected type comes from property 'x' which is declared here on type '{ x: "foo"; }' + foo5('foo', { x: 'bar' }) // error + ~ +!!! error TS2322: Type '"bar"' is not assignable to type '"foo"'. +!!! related TS6500 noInfer.ts:32:60: The expected type comes from property 'x' which is declared here on type 'NoInfer<{ x: "foo"; }>' + + declare class Animal { move(): void } + declare class Dog extends Animal { woof(): void } + declare function doSomething(value: T, getDefault: () => NoInfer): void; + + doSomething(new Animal(), () => new Animal()); // ok + doSomething(new Animal(), () => new Dog()); // ok + doSomething(new Dog(), () => new Animal()); // error + ~~~~~~~~~~~~ +!!! error TS2741: Property 'woof' is missing in type 'Animal' but required in type 'Dog'. +!!! related TS2728 noInfer.ts:42:36: 'woof' is declared here. +!!! related TS6502 noInfer.ts:43:55: The expected type comes from the return type of this signature. + + declare function assertEqual(actual: T, expected: NoInfer): boolean; + + assertEqual({ x: 1 }, { x: 3 }); // ok + const g = { x: 3, y: 2 }; + assertEqual(g, { x: 3 }); // error + ~~~~~~~~ +!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type '{ x: number; y: number; }'. +!!! error TS2345: Property 'y' is missing in type '{ x: number; }' but required in type '{ x: number; y: number; }'. +!!! related TS2728 noInfer.ts:52:19: 'y' is declared here. + + declare function invoke(func: (value: T) => R, value: NoInfer): R; + declare function test(value: { x: number; }): number; + + invoke(test, { x: 1, y: 2 }); // error + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. + test({ x: 1, y: 2 }); // error + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. + + type Component = { props: Props; }; + declare function doWork(Component: Component, props: NoInfer): void; + declare const comp: Component<{ foo: number }>; + + doWork(comp, { foo: 42 }); // ok + doWork(comp, {}); // error + ~~ +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ foo: number; }'. +!!! error TS2345: Property 'foo' is missing in type '{}' but required in type '{ foo: number; }'. +!!! related TS2728 noInfer.ts:63:33: 'foo' is declared here. + + declare function mutate(callback: (a: NoInfer, b: number) => T): T; + const mutate1 = mutate((a, b) => b); + + declare class ExampleClass {} + class OkClass { + constructor(private clazz: ExampleClass, private _value: NoInfer) {} + + get value(): T { + return this._value; // ok + } + } + class OkClass2 { + constructor(private clazz: ExampleClass, public _value: NoInfer) {} + } + \ No newline at end of file diff --git a/tests/baselines/reference/noInfer.js b/tests/baselines/reference/noInfer.js new file mode 100644 index 0000000000000..59e27f3755efd --- /dev/null +++ b/tests/baselines/reference/noInfer.js @@ -0,0 +1,202 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/noInfer.ts] //// + +//// [noInfer.ts] +// NoInfer is erased for primitives + +type T00 = NoInfer; +type T01 = NoInfer; +type T02 = NoInfer; +type T03 = NoInfer<"foo">; +type T04 = NoInfer<`foo${string}`>; +type T05 = NoInfer<`foo${string}` & `${string}bar`>; +type T06 = NoInfer<{}>; + +// NoInfer is preserved for object types + +type T10 = NoInfer; +type T11 = NoInfer<{ x: string }>; + +// NoInfer is erased if it has no effect + +type T20 = NoInfer>; +type T21 = NoInfer & string>; +type T22 = NoInfer & string[]>; + +// keyof NoInfer is transformed into NoInfer + +type T30 = keyof NoInfer<{ a: string, b: string }>; +type T31 = keyof NoInfer; +type T32 = { [K in keyof NoInfer<{ a: string, b: string }>]: K }; + +declare function foo1(a: T, b: NoInfer): void +declare function foo2(a: T, b: NoInfer[]): void +declare function foo3(a: T, b: NoInfer): void +declare function foo4(a: T, b: { x: NoInfer }): void +declare function foo5(a: T, b: NoInfer<{ x: T }>): void + +foo1('foo', 'foo') // ok +foo1('foo', 'bar') // error +foo2('foo', ['bar']) // error +foo3('foo', ['bar']) // error +foo4('foo', { x: 'bar' }) // error +foo5('foo', { x: 'bar' }) // error + +declare class Animal { move(): void } +declare class Dog extends Animal { woof(): void } +declare function doSomething(value: T, getDefault: () => NoInfer): void; + +doSomething(new Animal(), () => new Animal()); // ok +doSomething(new Animal(), () => new Dog()); // ok +doSomething(new Dog(), () => new Animal()); // error + +declare function assertEqual(actual: T, expected: NoInfer): boolean; + +assertEqual({ x: 1 }, { x: 3 }); // ok +const g = { x: 3, y: 2 }; +assertEqual(g, { x: 3 }); // error + +declare function invoke(func: (value: T) => R, value: NoInfer): R; +declare function test(value: { x: number; }): number; + +invoke(test, { x: 1, y: 2 }); // error +test({ x: 1, y: 2 }); // error + +type Component = { props: Props; }; +declare function doWork(Component: Component, props: NoInfer): void; +declare const comp: Component<{ foo: number }>; + +doWork(comp, { foo: 42 }); // ok +doWork(comp, {}); // error + +declare function mutate(callback: (a: NoInfer, b: number) => T): T; +const mutate1 = mutate((a, b) => b); + +declare class ExampleClass {} +class OkClass { + constructor(private clazz: ExampleClass, private _value: NoInfer) {} + + get value(): T { + return this._value; // ok + } +} +class OkClass2 { + constructor(private clazz: ExampleClass, public _value: NoInfer) {} +} + + +//// [noInfer.js] +"use strict"; +// NoInfer is erased for primitives +foo1('foo', 'foo'); // ok +foo1('foo', 'bar'); // error +foo2('foo', ['bar']); // error +foo3('foo', ['bar']); // error +foo4('foo', { x: 'bar' }); // error +foo5('foo', { x: 'bar' }); // error +doSomething(new Animal(), function () { return new Animal(); }); // ok +doSomething(new Animal(), function () { return new Dog(); }); // ok +doSomething(new Dog(), function () { return new Animal(); }); // error +assertEqual({ x: 1 }, { x: 3 }); // ok +var g = { x: 3, y: 2 }; +assertEqual(g, { x: 3 }); // error +invoke(test, { x: 1, y: 2 }); // error +test({ x: 1, y: 2 }); // error +doWork(comp, { foo: 42 }); // ok +doWork(comp, {}); // error +var mutate1 = mutate(function (a, b) { return b; }); +var OkClass = /** @class */ (function () { + function OkClass(clazz, _value) { + this.clazz = clazz; + this._value = _value; + } + Object.defineProperty(OkClass.prototype, "value", { + get: function () { + return this._value; // ok + }, + enumerable: false, + configurable: true + }); + return OkClass; +}()); +var OkClass2 = /** @class */ (function () { + function OkClass2(clazz, _value) { + this.clazz = clazz; + this._value = _value; + } + return OkClass2; +}()); + + +//// [noInfer.d.ts] +type T00 = NoInfer; +type T01 = NoInfer; +type T02 = NoInfer; +type T03 = NoInfer<"foo">; +type T04 = NoInfer<`foo${string}`>; +type T05 = NoInfer<`foo${string}` & `${string}bar`>; +type T06 = NoInfer<{}>; +type T10 = NoInfer; +type T11 = NoInfer<{ + x: string; +}>; +type T20 = NoInfer>; +type T21 = NoInfer & string>; +type T22 = NoInfer & string[]>; +type T30 = keyof NoInfer<{ + a: string; + b: string; +}>; +type T31 = keyof NoInfer; +type T32 = { + [K in keyof NoInfer<{ + a: string; + b: string; + }>]: K; +}; +declare function foo1(a: T, b: NoInfer): void; +declare function foo2(a: T, b: NoInfer[]): void; +declare function foo3(a: T, b: NoInfer): void; +declare function foo4(a: T, b: { + x: NoInfer; +}): void; +declare function foo5(a: T, b: NoInfer<{ + x: T; +}>): void; +declare class Animal { + move(): void; +} +declare class Dog extends Animal { + woof(): void; +} +declare function doSomething(value: T, getDefault: () => NoInfer): void; +declare function assertEqual(actual: T, expected: NoInfer): boolean; +declare const g: { + x: number; + y: number; +}; +declare function invoke(func: (value: T) => R, value: NoInfer): R; +declare function test(value: { + x: number; +}): number; +type Component = { + props: Props; +}; +declare function doWork(Component: Component, props: NoInfer): void; +declare const comp: Component<{ + foo: number; +}>; +declare function mutate(callback: (a: NoInfer, b: number) => T): T; +declare const mutate1: unknown; +declare class ExampleClass { +} +declare class OkClass { + private clazz; + private _value; + constructor(clazz: ExampleClass, _value: NoInfer); + get value(): T; +} +declare class OkClass2 { + private clazz; + _value: NoInfer; + constructor(clazz: ExampleClass, _value: NoInfer); +} diff --git a/tests/baselines/reference/noInfer.symbols b/tests/baselines/reference/noInfer.symbols new file mode 100644 index 0000000000000..7a36c6fccb9a1 --- /dev/null +++ b/tests/baselines/reference/noInfer.symbols @@ -0,0 +1,329 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/noInfer.ts] //// + +=== noInfer.ts === +// NoInfer is erased for primitives + +type T00 = NoInfer; +>T00 : Symbol(T00, Decl(noInfer.ts, 0, 0)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) + +type T01 = NoInfer; +>T01 : Symbol(T01, Decl(noInfer.ts, 2, 27)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) + +type T02 = NoInfer; +>T02 : Symbol(T02, Decl(noInfer.ts, 3, 46)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) + +type T03 = NoInfer<"foo">; +>T03 : Symbol(T03, Decl(noInfer.ts, 4, 30)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) + +type T04 = NoInfer<`foo${string}`>; +>T04 : Symbol(T04, Decl(noInfer.ts, 5, 26)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) + +type T05 = NoInfer<`foo${string}` & `${string}bar`>; +>T05 : Symbol(T05, Decl(noInfer.ts, 6, 35)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) + +type T06 = NoInfer<{}>; +>T06 : Symbol(T06, Decl(noInfer.ts, 7, 52)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) + +// NoInfer is preserved for object types + +type T10 = NoInfer; +>T10 : Symbol(T10, Decl(noInfer.ts, 8, 23)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) + +type T11 = NoInfer<{ x: string }>; +>T11 : Symbol(T11, Decl(noInfer.ts, 12, 29)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(noInfer.ts, 13, 20)) + +// NoInfer is erased if it has no effect + +type T20 = NoInfer>; +>T20 : Symbol(T20, Decl(noInfer.ts, 13, 34)) +>T : Symbol(T, Decl(noInfer.ts, 17, 9)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 17, 9)) + +type T21 = NoInfer & string>; +>T21 : Symbol(T21, Decl(noInfer.ts, 17, 34)) +>T : Symbol(T, Decl(noInfer.ts, 18, 9)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 18, 9)) + +type T22 = NoInfer & string[]>; +>T22 : Symbol(T22, Decl(noInfer.ts, 18, 43)) +>T : Symbol(T, Decl(noInfer.ts, 19, 9)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 19, 9)) + +// keyof NoInfer is transformed into NoInfer + +type T30 = keyof NoInfer<{ a: string, b: string }>; +>T30 : Symbol(T30, Decl(noInfer.ts, 19, 45)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(noInfer.ts, 23, 26)) +>b : Symbol(b, Decl(noInfer.ts, 23, 37)) + +type T31 = keyof NoInfer; +>T31 : Symbol(T31, Decl(noInfer.ts, 23, 51)) +>T : Symbol(T, Decl(noInfer.ts, 24, 9)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 24, 9)) + +type T32 = { [K in keyof NoInfer<{ a: string, b: string }>]: K }; +>T32 : Symbol(T32, Decl(noInfer.ts, 24, 31)) +>K : Symbol(K, Decl(noInfer.ts, 25, 14)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(noInfer.ts, 25, 34)) +>b : Symbol(b, Decl(noInfer.ts, 25, 45)) +>K : Symbol(K, Decl(noInfer.ts, 25, 14)) + +declare function foo1(a: T, b: NoInfer): void +>foo1 : Symbol(foo1, Decl(noInfer.ts, 25, 65)) +>T : Symbol(T, Decl(noInfer.ts, 27, 22)) +>a : Symbol(a, Decl(noInfer.ts, 27, 40)) +>T : Symbol(T, Decl(noInfer.ts, 27, 22)) +>b : Symbol(b, Decl(noInfer.ts, 27, 45)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 27, 22)) + +declare function foo2(a: T, b: NoInfer[]): void +>foo2 : Symbol(foo2, Decl(noInfer.ts, 27, 66)) +>T : Symbol(T, Decl(noInfer.ts, 28, 22)) +>a : Symbol(a, Decl(noInfer.ts, 28, 40)) +>T : Symbol(T, Decl(noInfer.ts, 28, 22)) +>b : Symbol(b, Decl(noInfer.ts, 28, 45)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 28, 22)) + +declare function foo3(a: T, b: NoInfer): void +>foo3 : Symbol(foo3, Decl(noInfer.ts, 28, 68)) +>T : Symbol(T, Decl(noInfer.ts, 29, 22)) +>a : Symbol(a, Decl(noInfer.ts, 29, 40)) +>T : Symbol(T, Decl(noInfer.ts, 29, 22)) +>b : Symbol(b, Decl(noInfer.ts, 29, 45)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 29, 22)) + +declare function foo4(a: T, b: { x: NoInfer }): void +>foo4 : Symbol(foo4, Decl(noInfer.ts, 29, 68)) +>T : Symbol(T, Decl(noInfer.ts, 30, 22)) +>a : Symbol(a, Decl(noInfer.ts, 30, 40)) +>T : Symbol(T, Decl(noInfer.ts, 30, 22)) +>b : Symbol(b, Decl(noInfer.ts, 30, 45)) +>x : Symbol(x, Decl(noInfer.ts, 30, 50)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 30, 22)) + +declare function foo5(a: T, b: NoInfer<{ x: T }>): void +>foo5 : Symbol(foo5, Decl(noInfer.ts, 30, 73)) +>T : Symbol(T, Decl(noInfer.ts, 31, 22)) +>a : Symbol(a, Decl(noInfer.ts, 31, 40)) +>T : Symbol(T, Decl(noInfer.ts, 31, 22)) +>b : Symbol(b, Decl(noInfer.ts, 31, 45)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(noInfer.ts, 31, 58)) +>T : Symbol(T, Decl(noInfer.ts, 31, 22)) + +foo1('foo', 'foo') // ok +>foo1 : Symbol(foo1, Decl(noInfer.ts, 25, 65)) + +foo1('foo', 'bar') // error +>foo1 : Symbol(foo1, Decl(noInfer.ts, 25, 65)) + +foo2('foo', ['bar']) // error +>foo2 : Symbol(foo2, Decl(noInfer.ts, 27, 66)) + +foo3('foo', ['bar']) // error +>foo3 : Symbol(foo3, Decl(noInfer.ts, 28, 68)) + +foo4('foo', { x: 'bar' }) // error +>foo4 : Symbol(foo4, Decl(noInfer.ts, 29, 68)) +>x : Symbol(x, Decl(noInfer.ts, 37, 13)) + +foo5('foo', { x: 'bar' }) // error +>foo5 : Symbol(foo5, Decl(noInfer.ts, 30, 73)) +>x : Symbol(x, Decl(noInfer.ts, 38, 13)) + +declare class Animal { move(): void } +>Animal : Symbol(Animal, Decl(noInfer.ts, 38, 25)) +>move : Symbol(Animal.move, Decl(noInfer.ts, 40, 22)) + +declare class Dog extends Animal { woof(): void } +>Dog : Symbol(Dog, Decl(noInfer.ts, 40, 37)) +>Animal : Symbol(Animal, Decl(noInfer.ts, 38, 25)) +>woof : Symbol(Dog.woof, Decl(noInfer.ts, 41, 34)) + +declare function doSomething(value: T, getDefault: () => NoInfer): void; +>doSomething : Symbol(doSomething, Decl(noInfer.ts, 41, 49)) +>T : Symbol(T, Decl(noInfer.ts, 42, 29)) +>value : Symbol(value, Decl(noInfer.ts, 42, 32)) +>T : Symbol(T, Decl(noInfer.ts, 42, 29)) +>getDefault : Symbol(getDefault, Decl(noInfer.ts, 42, 41)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 42, 29)) + +doSomething(new Animal(), () => new Animal()); // ok +>doSomething : Symbol(doSomething, Decl(noInfer.ts, 41, 49)) +>Animal : Symbol(Animal, Decl(noInfer.ts, 38, 25)) +>Animal : Symbol(Animal, Decl(noInfer.ts, 38, 25)) + +doSomething(new Animal(), () => new Dog()); // ok +>doSomething : Symbol(doSomething, Decl(noInfer.ts, 41, 49)) +>Animal : Symbol(Animal, Decl(noInfer.ts, 38, 25)) +>Dog : Symbol(Dog, Decl(noInfer.ts, 40, 37)) + +doSomething(new Dog(), () => new Animal()); // error +>doSomething : Symbol(doSomething, Decl(noInfer.ts, 41, 49)) +>Dog : Symbol(Dog, Decl(noInfer.ts, 40, 37)) +>Animal : Symbol(Animal, Decl(noInfer.ts, 38, 25)) + +declare function assertEqual(actual: T, expected: NoInfer): boolean; +>assertEqual : Symbol(assertEqual, Decl(noInfer.ts, 46, 43)) +>T : Symbol(T, Decl(noInfer.ts, 48, 29)) +>actual : Symbol(actual, Decl(noInfer.ts, 48, 32)) +>T : Symbol(T, Decl(noInfer.ts, 48, 29)) +>expected : Symbol(expected, Decl(noInfer.ts, 48, 42)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 48, 29)) + +assertEqual({ x: 1 }, { x: 3 }); // ok +>assertEqual : Symbol(assertEqual, Decl(noInfer.ts, 46, 43)) +>x : Symbol(x, Decl(noInfer.ts, 50, 13)) +>x : Symbol(x, Decl(noInfer.ts, 50, 23)) + +const g = { x: 3, y: 2 }; +>g : Symbol(g, Decl(noInfer.ts, 51, 5)) +>x : Symbol(x, Decl(noInfer.ts, 51, 11)) +>y : Symbol(y, Decl(noInfer.ts, 51, 17)) + +assertEqual(g, { x: 3 }); // error +>assertEqual : Symbol(assertEqual, Decl(noInfer.ts, 46, 43)) +>g : Symbol(g, Decl(noInfer.ts, 51, 5)) +>x : Symbol(x, Decl(noInfer.ts, 52, 16)) + +declare function invoke(func: (value: T) => R, value: NoInfer): R; +>invoke : Symbol(invoke, Decl(noInfer.ts, 52, 25)) +>T : Symbol(T, Decl(noInfer.ts, 54, 24)) +>R : Symbol(R, Decl(noInfer.ts, 54, 26)) +>func : Symbol(func, Decl(noInfer.ts, 54, 30)) +>value : Symbol(value, Decl(noInfer.ts, 54, 37)) +>T : Symbol(T, Decl(noInfer.ts, 54, 24)) +>R : Symbol(R, Decl(noInfer.ts, 54, 26)) +>value : Symbol(value, Decl(noInfer.ts, 54, 52)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 54, 24)) +>R : Symbol(R, Decl(noInfer.ts, 54, 26)) + +declare function test(value: { x: number; }): number; +>test : Symbol(test, Decl(noInfer.ts, 54, 75)) +>value : Symbol(value, Decl(noInfer.ts, 55, 22)) +>x : Symbol(x, Decl(noInfer.ts, 55, 30)) + +invoke(test, { x: 1, y: 2 }); // error +>invoke : Symbol(invoke, Decl(noInfer.ts, 52, 25)) +>test : Symbol(test, Decl(noInfer.ts, 54, 75)) +>x : Symbol(x, Decl(noInfer.ts, 57, 14)) +>y : Symbol(y, Decl(noInfer.ts, 57, 20)) + +test({ x: 1, y: 2 }); // error +>test : Symbol(test, Decl(noInfer.ts, 54, 75)) +>x : Symbol(x, Decl(noInfer.ts, 58, 6)) +>y : Symbol(y, Decl(noInfer.ts, 58, 12)) + +type Component = { props: Props; }; +>Component : Symbol(Component, Decl(noInfer.ts, 58, 21)) +>Props : Symbol(Props, Decl(noInfer.ts, 60, 15)) +>props : Symbol(props, Decl(noInfer.ts, 60, 25)) +>Props : Symbol(Props, Decl(noInfer.ts, 60, 15)) + +declare function doWork(Component: Component, props: NoInfer): void; +>doWork : Symbol(doWork, Decl(noInfer.ts, 60, 42)) +>Props : Symbol(Props, Decl(noInfer.ts, 61, 24)) +>Component : Symbol(Component, Decl(noInfer.ts, 61, 31)) +>Component : Symbol(Component, Decl(noInfer.ts, 58, 21)) +>Props : Symbol(Props, Decl(noInfer.ts, 61, 24)) +>props : Symbol(props, Decl(noInfer.ts, 61, 59)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>Props : Symbol(Props, Decl(noInfer.ts, 61, 24)) + +declare const comp: Component<{ foo: number }>; +>comp : Symbol(comp, Decl(noInfer.ts, 62, 13)) +>Component : Symbol(Component, Decl(noInfer.ts, 58, 21)) +>foo : Symbol(foo, Decl(noInfer.ts, 62, 31)) + +doWork(comp, { foo: 42 }); // ok +>doWork : Symbol(doWork, Decl(noInfer.ts, 60, 42)) +>comp : Symbol(comp, Decl(noInfer.ts, 62, 13)) +>foo : Symbol(foo, Decl(noInfer.ts, 64, 14)) + +doWork(comp, {}); // error +>doWork : Symbol(doWork, Decl(noInfer.ts, 60, 42)) +>comp : Symbol(comp, Decl(noInfer.ts, 62, 13)) + +declare function mutate(callback: (a: NoInfer, b: number) => T): T; +>mutate : Symbol(mutate, Decl(noInfer.ts, 65, 17)) +>T : Symbol(T, Decl(noInfer.ts, 67, 24)) +>callback : Symbol(callback, Decl(noInfer.ts, 67, 27)) +>a : Symbol(a, Decl(noInfer.ts, 67, 38)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 67, 24)) +>b : Symbol(b, Decl(noInfer.ts, 67, 52)) +>T : Symbol(T, Decl(noInfer.ts, 67, 24)) +>T : Symbol(T, Decl(noInfer.ts, 67, 24)) + +const mutate1 = mutate((a, b) => b); +>mutate1 : Symbol(mutate1, Decl(noInfer.ts, 68, 5)) +>mutate : Symbol(mutate, Decl(noInfer.ts, 65, 17)) +>a : Symbol(a, Decl(noInfer.ts, 68, 24)) +>b : Symbol(b, Decl(noInfer.ts, 68, 26)) +>b : Symbol(b, Decl(noInfer.ts, 68, 26)) + +declare class ExampleClass {} +>ExampleClass : Symbol(ExampleClass, Decl(noInfer.ts, 68, 36)) +>T : Symbol(T, Decl(noInfer.ts, 70, 27)) + +class OkClass { +>OkClass : Symbol(OkClass, Decl(noInfer.ts, 70, 32)) +>T : Symbol(T, Decl(noInfer.ts, 71, 14)) + + constructor(private clazz: ExampleClass, private _value: NoInfer) {} +>clazz : Symbol(OkClass.clazz, Decl(noInfer.ts, 72, 16)) +>ExampleClass : Symbol(ExampleClass, Decl(noInfer.ts, 68, 36)) +>T : Symbol(T, Decl(noInfer.ts, 71, 14)) +>_value : Symbol(OkClass._value, Decl(noInfer.ts, 72, 47)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 71, 14)) + + get value(): T { +>value : Symbol(OkClass.value, Decl(noInfer.ts, 72, 78)) +>T : Symbol(T, Decl(noInfer.ts, 71, 14)) + + return this._value; // ok +>this._value : Symbol(OkClass._value, Decl(noInfer.ts, 72, 47)) +>this : Symbol(OkClass, Decl(noInfer.ts, 70, 32)) +>_value : Symbol(OkClass._value, Decl(noInfer.ts, 72, 47)) + } +} +class OkClass2 { +>OkClass2 : Symbol(OkClass2, Decl(noInfer.ts, 77, 1)) +>T : Symbol(T, Decl(noInfer.ts, 78, 15)) + + constructor(private clazz: ExampleClass, public _value: NoInfer) {} +>clazz : Symbol(OkClass2.clazz, Decl(noInfer.ts, 79, 16)) +>ExampleClass : Symbol(ExampleClass, Decl(noInfer.ts, 68, 36)) +>T : Symbol(T, Decl(noInfer.ts, 78, 15)) +>_value : Symbol(OkClass2._value, Decl(noInfer.ts, 79, 47)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(noInfer.ts, 78, 15)) +} + diff --git a/tests/baselines/reference/noInfer.types b/tests/baselines/reference/noInfer.types new file mode 100644 index 0000000000000..0b747c064a450 --- /dev/null +++ b/tests/baselines/reference/noInfer.types @@ -0,0 +1,301 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/noInfer.ts] //// + +=== noInfer.ts === +// NoInfer is erased for primitives + +type T00 = NoInfer; +>T00 : string + +type T01 = NoInfer; +>T01 : string | number | boolean + +type T02 = NoInfer; +>T02 : undefined + +type T03 = NoInfer<"foo">; +>T03 : "foo" + +type T04 = NoInfer<`foo${string}`>; +>T04 : `foo${string}` + +type T05 = NoInfer<`foo${string}` & `${string}bar`>; +>T05 : `foo${string}` & `${string}bar` + +type T06 = NoInfer<{}>; +>T06 : {} + +// NoInfer is preserved for object types + +type T10 = NoInfer; +>T10 : NoInfer + +type T11 = NoInfer<{ x: string }>; +>T11 : NoInfer<{ x: string; }> +>x : string + +// NoInfer is erased if it has no effect + +type T20 = NoInfer>; +>T20 : NoInfer + +type T21 = NoInfer & string>; +>T21 : NoInfer & string + +type T22 = NoInfer & string[]>; +>T22 : NoInfer & string[]> + +// keyof NoInfer is transformed into NoInfer + +type T30 = keyof NoInfer<{ a: string, b: string }>; +>T30 : "a" | "b" +>a : string +>b : string + +type T31 = keyof NoInfer; +>T31 : NoInfer + +type T32 = { [K in keyof NoInfer<{ a: string, b: string }>]: K }; +>T32 : { a: "a"; b: "b"; } +>a : string +>b : string + +declare function foo1(a: T, b: NoInfer): void +>foo1 : (a: T, b: NoInfer) => void +>a : T +>b : NoInfer + +declare function foo2(a: T, b: NoInfer[]): void +>foo2 : (a: T, b: NoInfer[]) => void +>a : T +>b : NoInfer[] + +declare function foo3(a: T, b: NoInfer): void +>foo3 : (a: T, b: NoInfer) => void +>a : T +>b : NoInfer + +declare function foo4(a: T, b: { x: NoInfer }): void +>foo4 : (a: T, b: { x: NoInfer;}) => void +>a : T +>b : { x: NoInfer; } +>x : NoInfer + +declare function foo5(a: T, b: NoInfer<{ x: T }>): void +>foo5 : (a: T, b: NoInfer<{ x: T;}>) => void +>a : T +>b : NoInfer<{ x: T; }> +>x : T + +foo1('foo', 'foo') // ok +>foo1('foo', 'foo') : void +>foo1 : (a: T, b: NoInfer) => void +>'foo' : "foo" +>'foo' : "foo" + +foo1('foo', 'bar') // error +>foo1('foo', 'bar') : void +>foo1 : (a: T, b: NoInfer) => void +>'foo' : "foo" +>'bar' : "bar" + +foo2('foo', ['bar']) // error +>foo2('foo', ['bar']) : void +>foo2 : (a: T, b: NoInfer[]) => void +>'foo' : "foo" +>['bar'] : "bar"[] +>'bar' : "bar" + +foo3('foo', ['bar']) // error +>foo3('foo', ['bar']) : void +>foo3 : (a: T, b: NoInfer) => void +>'foo' : "foo" +>['bar'] : "bar"[] +>'bar' : "bar" + +foo4('foo', { x: 'bar' }) // error +>foo4('foo', { x: 'bar' }) : void +>foo4 : (a: T, b: { x: NoInfer; }) => void +>'foo' : "foo" +>{ x: 'bar' } : { x: "bar"; } +>x : "bar" +>'bar' : "bar" + +foo5('foo', { x: 'bar' }) // error +>foo5('foo', { x: 'bar' }) : void +>foo5 : (a: T, b: NoInfer<{ x: T; }>) => void +>'foo' : "foo" +>{ x: 'bar' } : { x: "bar"; } +>x : "bar" +>'bar' : "bar" + +declare class Animal { move(): void } +>Animal : Animal +>move : () => void + +declare class Dog extends Animal { woof(): void } +>Dog : Dog +>Animal : Animal +>woof : () => void + +declare function doSomething(value: T, getDefault: () => NoInfer): void; +>doSomething : (value: T, getDefault: () => NoInfer) => void +>value : T +>getDefault : () => NoInfer + +doSomething(new Animal(), () => new Animal()); // ok +>doSomething(new Animal(), () => new Animal()) : void +>doSomething : (value: T, getDefault: () => NoInfer) => void +>new Animal() : Animal +>Animal : typeof Animal +>() => new Animal() : () => Animal +>new Animal() : Animal +>Animal : typeof Animal + +doSomething(new Animal(), () => new Dog()); // ok +>doSomething(new Animal(), () => new Dog()) : void +>doSomething : (value: T, getDefault: () => NoInfer) => void +>new Animal() : Animal +>Animal : typeof Animal +>() => new Dog() : () => Dog +>new Dog() : Dog +>Dog : typeof Dog + +doSomething(new Dog(), () => new Animal()); // error +>doSomething(new Dog(), () => new Animal()) : void +>doSomething : (value: T, getDefault: () => NoInfer) => void +>new Dog() : Dog +>Dog : typeof Dog +>() => new Animal() : () => Animal +>new Animal() : Animal +>Animal : typeof Animal + +declare function assertEqual(actual: T, expected: NoInfer): boolean; +>assertEqual : (actual: T, expected: NoInfer) => boolean +>actual : T +>expected : NoInfer + +assertEqual({ x: 1 }, { x: 3 }); // ok +>assertEqual({ x: 1 }, { x: 3 }) : boolean +>assertEqual : (actual: T, expected: NoInfer) => boolean +>{ x: 1 } : { x: number; } +>x : number +>1 : 1 +>{ x: 3 } : { x: number; } +>x : number +>3 : 3 + +const g = { x: 3, y: 2 }; +>g : { x: number; y: number; } +>{ x: 3, y: 2 } : { x: number; y: number; } +>x : number +>3 : 3 +>y : number +>2 : 2 + +assertEqual(g, { x: 3 }); // error +>assertEqual(g, { x: 3 }) : boolean +>assertEqual : (actual: T, expected: NoInfer) => boolean +>g : { x: number; y: number; } +>{ x: 3 } : { x: number; } +>x : number +>3 : 3 + +declare function invoke(func: (value: T) => R, value: NoInfer): R; +>invoke : (func: (value: T) => R, value: NoInfer) => R +>func : (value: T) => R +>value : T +>value : NoInfer + +declare function test(value: { x: number; }): number; +>test : (value: { x: number;}) => number +>value : { x: number; } +>x : number + +invoke(test, { x: 1, y: 2 }); // error +>invoke(test, { x: 1, y: 2 }) : number +>invoke : (func: (value: T) => R, value: NoInfer) => R +>test : (value: { x: number; }) => number +>{ x: 1, y: 2 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>2 : 2 + +test({ x: 1, y: 2 }); // error +>test({ x: 1, y: 2 }) : number +>test : (value: { x: number; }) => number +>{ x: 1, y: 2 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>2 : 2 + +type Component = { props: Props; }; +>Component : Component +>props : Props + +declare function doWork(Component: Component, props: NoInfer): void; +>doWork : (Component: Component, props: NoInfer) => void +>Component : Component +>props : NoInfer + +declare const comp: Component<{ foo: number }>; +>comp : Component<{ foo: number; }> +>foo : number + +doWork(comp, { foo: 42 }); // ok +>doWork(comp, { foo: 42 }) : void +>doWork : (Component: Component, props: NoInfer) => void +>comp : Component<{ foo: number; }> +>{ foo: 42 } : { foo: number; } +>foo : number +>42 : 42 + +doWork(comp, {}); // error +>doWork(comp, {}) : void +>doWork : (Component: Component, props: NoInfer) => void +>comp : Component<{ foo: number; }> +>{} : {} + +declare function mutate(callback: (a: NoInfer, b: number) => T): T; +>mutate : (callback: (a: NoInfer, b: number) => T) => T +>callback : (a: NoInfer, b: number) => T +>a : NoInfer +>b : number + +const mutate1 = mutate((a, b) => b); +>mutate1 : unknown +>mutate((a, b) => b) : unknown +>mutate : (callback: (a: NoInfer, b: number) => T) => T +>(a, b) => b : (a: unknown, b: number) => number +>a : unknown +>b : number +>b : number + +declare class ExampleClass {} +>ExampleClass : ExampleClass + +class OkClass { +>OkClass : OkClass + + constructor(private clazz: ExampleClass, private _value: NoInfer) {} +>clazz : ExampleClass +>_value : NoInfer + + get value(): T { +>value : T + + return this._value; // ok +>this._value : NoInfer +>this : this +>_value : NoInfer + } +} +class OkClass2 { +>OkClass2 : OkClass2 + + constructor(private clazz: ExampleClass, public _value: NoInfer) {} +>clazz : ExampleClass +>_value : NoInfer +} + diff --git a/tests/baselines/reference/noInferRedeclaration.js b/tests/baselines/reference/noInferRedeclaration.js new file mode 100644 index 0000000000000..a9afd9107f829 --- /dev/null +++ b/tests/baselines/reference/noInferRedeclaration.js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts] //// + +//// [a.ts] +export const f = (x: T, y: NoInfer) => x; + +//// [b.ts] +import { f } from "./a"; + +type NoInfer = T & number; + +export const g = f; + + +//// [a.js] +export const f = (x, y) => x; +//// [b.js] +import { f } from "./a"; +export const g = f; + + +//// [a.d.ts] +export declare const f: (x: T, y: NoInfer) => T; +//// [b.d.ts] +export declare const g: (x: T, y: globalThis.NoInfer) => T; diff --git a/tests/baselines/reference/noInferRedeclaration.symbols b/tests/baselines/reference/noInferRedeclaration.symbols new file mode 100644 index 0000000000000..b7b3bb5529c86 --- /dev/null +++ b/tests/baselines/reference/noInferRedeclaration.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts] //// + +=== a.ts === +export const f = (x: T, y: NoInfer) => x; +>f : Symbol(f, Decl(a.ts, 0, 12)) +>T : Symbol(T, Decl(a.ts, 0, 18)) +>x : Symbol(x, Decl(a.ts, 0, 21)) +>T : Symbol(T, Decl(a.ts, 0, 18)) +>y : Symbol(y, Decl(a.ts, 0, 26)) +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(a.ts, 0, 18)) +>x : Symbol(x, Decl(a.ts, 0, 21)) + +=== b.ts === +import { f } from "./a"; +>f : Symbol(f, Decl(b.ts, 0, 8)) + +type NoInfer = T & number; +>NoInfer : Symbol(NoInfer, Decl(b.ts, 0, 24)) +>T : Symbol(T, Decl(b.ts, 2, 13)) +>T : Symbol(T, Decl(b.ts, 2, 13)) + +export const g = f; +>g : Symbol(g, Decl(b.ts, 4, 12)) +>f : Symbol(f, Decl(b.ts, 0, 8)) + diff --git a/tests/baselines/reference/noInferRedeclaration.types b/tests/baselines/reference/noInferRedeclaration.types new file mode 100644 index 0000000000000..0d8f54db5e4ef --- /dev/null +++ b/tests/baselines/reference/noInferRedeclaration.types @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts] //// + +=== a.ts === +export const f = (x: T, y: NoInfer) => x; +>f : (x: T, y: NoInfer) => T +>(x: T, y: NoInfer) => x : (x: T, y: NoInfer) => T +>x : T +>y : NoInfer +>x : T + +=== b.ts === +import { f } from "./a"; +>f : (x: T, y: globalThis.NoInfer) => T + +type NoInfer = T & number; +>NoInfer : NoInfer + +export const g = f; +>g : (x: T, y: globalThis.NoInfer) => T +>f : (x: T, y: globalThis.NoInfer) => T + diff --git a/tests/baselines/reference/objectGroupBy.errors.txt b/tests/baselines/reference/objectGroupBy.errors.txt new file mode 100644 index 0000000000000..b748dc72da416 --- /dev/null +++ b/tests/baselines/reference/objectGroupBy.errors.txt @@ -0,0 +1,17 @@ +objectGroupBy.ts(9,49): error TS2322: Type 'Employee' is not assignable to type 'PropertyKey'. + + +==== objectGroupBy.ts (1 errors) ==== + const basic = Object.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); + + const chars = Object.groupBy('a string', c => c); + + type Employee = { name: string, role: 'ic' | 'manager' } + const employees: Set = new Set(); + const byRole = Object.groupBy(employees, x => x.role); + + const byNonKey = Object.groupBy(employees, x => x); + ~ +!!! error TS2322: Type 'Employee' is not assignable to type 'PropertyKey'. +!!! related TS6502 lib.esnext.object.d.ts:--:--: The expected type comes from the return type of this signature. + \ No newline at end of file diff --git a/tests/baselines/reference/objectGroupBy.js b/tests/baselines/reference/objectGroupBy.js new file mode 100644 index 0000000000000..320475a1a427c --- /dev/null +++ b/tests/baselines/reference/objectGroupBy.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/objectGroupBy.ts] //// + +//// [objectGroupBy.ts] +const basic = Object.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); + +const chars = Object.groupBy('a string', c => c); + +type Employee = { name: string, role: 'ic' | 'manager' } +const employees: Set = new Set(); +const byRole = Object.groupBy(employees, x => x.role); + +const byNonKey = Object.groupBy(employees, x => x); + + +//// [objectGroupBy.js] +const basic = Object.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); +const chars = Object.groupBy('a string', c => c); +const employees = new Set(); +const byRole = Object.groupBy(employees, x => x.role); +const byNonKey = Object.groupBy(employees, x => x); diff --git a/tests/baselines/reference/objectGroupBy.symbols b/tests/baselines/reference/objectGroupBy.symbols new file mode 100644 index 0000000000000..df5e44fbf3c16 --- /dev/null +++ b/tests/baselines/reference/objectGroupBy.symbols @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/objectGroupBy.ts] //// + +=== objectGroupBy.ts === +const basic = Object.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); +>basic : Symbol(basic, Decl(objectGroupBy.ts, 0, 5)) +>Object.groupBy : Symbol(ObjectConstructor.groupBy, Decl(lib.esnext.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>groupBy : Symbol(ObjectConstructor.groupBy, Decl(lib.esnext.object.d.ts, --, --)) +>x : Symbol(x, Decl(objectGroupBy.ts, 0, 39)) +>x : Symbol(x, Decl(objectGroupBy.ts, 0, 39)) + +const chars = Object.groupBy('a string', c => c); +>chars : Symbol(chars, Decl(objectGroupBy.ts, 2, 5)) +>Object.groupBy : Symbol(ObjectConstructor.groupBy, Decl(lib.esnext.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>groupBy : Symbol(ObjectConstructor.groupBy, Decl(lib.esnext.object.d.ts, --, --)) +>c : Symbol(c, Decl(objectGroupBy.ts, 2, 40)) +>c : Symbol(c, Decl(objectGroupBy.ts, 2, 40)) + +type Employee = { name: string, role: 'ic' | 'manager' } +>Employee : Symbol(Employee, Decl(objectGroupBy.ts, 2, 49)) +>name : Symbol(name, Decl(objectGroupBy.ts, 4, 17)) +>role : Symbol(role, Decl(objectGroupBy.ts, 4, 31)) + +const employees: Set = new Set(); +>employees : Symbol(employees, Decl(objectGroupBy.ts, 5, 5)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>Employee : Symbol(Employee, Decl(objectGroupBy.ts, 2, 49)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +const byRole = Object.groupBy(employees, x => x.role); +>byRole : Symbol(byRole, Decl(objectGroupBy.ts, 6, 5)) +>Object.groupBy : Symbol(ObjectConstructor.groupBy, Decl(lib.esnext.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>groupBy : Symbol(ObjectConstructor.groupBy, Decl(lib.esnext.object.d.ts, --, --)) +>employees : Symbol(employees, Decl(objectGroupBy.ts, 5, 5)) +>x : Symbol(x, Decl(objectGroupBy.ts, 6, 40)) +>x.role : Symbol(role, Decl(objectGroupBy.ts, 4, 31)) +>x : Symbol(x, Decl(objectGroupBy.ts, 6, 40)) +>role : Symbol(role, Decl(objectGroupBy.ts, 4, 31)) + +const byNonKey = Object.groupBy(employees, x => x); +>byNonKey : Symbol(byNonKey, Decl(objectGroupBy.ts, 8, 5)) +>Object.groupBy : Symbol(ObjectConstructor.groupBy, Decl(lib.esnext.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>groupBy : Symbol(ObjectConstructor.groupBy, Decl(lib.esnext.object.d.ts, --, --)) +>employees : Symbol(employees, Decl(objectGroupBy.ts, 5, 5)) +>x : Symbol(x, Decl(objectGroupBy.ts, 8, 42)) +>x : Symbol(x, Decl(objectGroupBy.ts, 8, 42)) + diff --git a/tests/baselines/reference/objectGroupBy.types b/tests/baselines/reference/objectGroupBy.types new file mode 100644 index 0000000000000..1fb901e8edb83 --- /dev/null +++ b/tests/baselines/reference/objectGroupBy.types @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/objectGroupBy.ts] //// + +=== objectGroupBy.ts === +const basic = Object.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); +>basic : Partial> +>Object.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large') : Partial> +>Object.groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Partial> +>Object : ObjectConstructor +>groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Partial> +>[0, 2, 8] : number[] +>0 : 0 +>2 : 2 +>8 : 8 +>x => x < 5 ? 'small' : 'large' : (x: number) => "small" | "large" +>x : number +>x < 5 ? 'small' : 'large' : "small" | "large" +>x < 5 : boolean +>x : number +>5 : 5 +>'small' : "small" +>'large' : "large" + +const chars = Object.groupBy('a string', c => c); +>chars : Partial> +>Object.groupBy('a string', c => c) : Partial> +>Object.groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Partial> +>Object : ObjectConstructor +>groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Partial> +>'a string' : "a string" +>c => c : (c: string) => string +>c : string +>c : string + +type Employee = { name: string, role: 'ic' | 'manager' } +>Employee : { name: string; role: 'ic' | 'manager'; } +>name : string +>role : "ic" | "manager" + +const employees: Set = new Set(); +>employees : Set +>new Set() : Set +>Set : SetConstructor + +const byRole = Object.groupBy(employees, x => x.role); +>byRole : Partial> +>Object.groupBy(employees, x => x.role) : Partial> +>Object.groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Partial> +>Object : ObjectConstructor +>groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Partial> +>employees : Set +>x => x.role : (x: Employee) => "ic" | "manager" +>x : Employee +>x.role : "ic" | "manager" +>x : Employee +>role : "ic" | "manager" + +const byNonKey = Object.groupBy(employees, x => x); +>byNonKey : Partial> +>Object.groupBy(employees, x => x) : Partial> +>Object.groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Partial> +>Object : ObjectConstructor +>groupBy : (items: Iterable, keySelector: (item: T, index: number) => K) => Partial> +>employees : Set +>x => x : (x: Employee) => Employee +>x : Employee +>x : Employee + diff --git a/tests/baselines/reference/paramterDestrcuturingDeclaration.js b/tests/baselines/reference/paramterDestrcuturingDeclaration.js index 69b176dc50d35..86d8e41a90358 100644 --- a/tests/baselines/reference/paramterDestrcuturingDeclaration.js +++ b/tests/baselines/reference/paramterDestrcuturingDeclaration.js @@ -12,10 +12,10 @@ interface C { //// [paramterDestrcuturingDeclaration.d.ts] interface C { - ({ p }: { + ({ p: name }: { p: any; }): any; - new ({ p }: { + new ({ p: boolean }: { p: any; }): any; } diff --git a/tests/baselines/reference/quickInfoJsDocTags15.baseline b/tests/baselines/reference/quickInfoJsDocTags15.baseline new file mode 100644 index 0000000000000..da5ff2162dba0 --- /dev/null +++ b/tests/baselines/reference/quickInfoJsDocTags15.baseline @@ -0,0 +1,308 @@ +// === QuickInfo === +=== /b.js === +// import * as _a from "./a.js"; +// /** +// * @implements {_a.Foo} +// ^^^ +// | ---------------------------------------------------------------------- +// | type Foo = { +// | getName: _a.Bar; +// | } +// | ---------------------------------------------------------------------- +// */ +// class C1 { } +// +// /** +// * @extends {_a.Foo} +// ^^^ +// | ---------------------------------------------------------------------- +// | type Foo = { +// | getName: _a.Bar; +// | } +// | ---------------------------------------------------------------------- +// */ +// class C2 { } +// +// /** +// * @augments {_a.Foo} +// ^^^ +// | ---------------------------------------------------------------------- +// | type Foo = { +// | getName: _a.Bar; +// | } +// | ---------------------------------------------------------------------- +// */ +// class C3 { } + +[ + { + "marker": { + "fileName": "/b.js", + "position": 56, + "name": "1" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 53, + "length": 3 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getName", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "_a", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Bar", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [] + } + }, + { + "marker": { + "fileName": "/b.js", + "position": 99, + "name": "2" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 3 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getName", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "_a", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Bar", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [] + } + }, + { + "marker": { + "fileName": "/b.js", + "position": 143, + "name": "3" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 140, + "length": 3 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getName", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "_a", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Bar", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [] + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.js b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.js index f3595a69e4846..af19e36e72147 100644 --- a/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.js +++ b/tests/baselines/reference/renamingDestructuredPropertyInFunctionType.js @@ -101,14 +101,14 @@ type O = { c: number; }; type F1 = (arg: number) => any; -type F2 = ({ a }: O) => any; -type F3 = ({ a, b, c }: O) => any; -type F4 = ({ a }: O) => any; -type F5 = ({ a, b, c }: O) => any; +type F2 = ({ a: string }: O) => any; +type F3 = ({ a: string, b, c }: O) => any; +type F4 = ({ a: string }: O) => any; +type F5 = ({ a: string, b, c }: O) => any; type F6 = ({ a: string }: { a: any; }) => typeof string; -type F7 = ({ a, b: number }: { +type F7 = ({ a: string, b: number }: { a: any; b: any; }) => typeof number; @@ -118,14 +118,14 @@ type F8 = ({ a, b: number }: { }) => typeof number; type F9 = ([a, b, c]: [any, any, any]) => void; type G1 = new (arg: number) => any; -type G2 = new ({ a }: O) => any; -type G3 = new ({ a, b, c }: O) => any; -type G4 = new ({ a }: O) => any; -type G5 = new ({ a, b, c }: O) => any; +type G2 = new ({ a: string }: O) => any; +type G3 = new ({ a: string, b, c }: O) => any; +type G4 = new ({ a: string }: O) => any; +type G5 = new ({ a: string, b, c }: O) => any; type G6 = new ({ a: string }: { a: any; }) => typeof string; -type G7 = new ({ a, b: number }: { +type G7 = new ({ a: string, b: number }: { a: any; b: any; }) => typeof number; @@ -156,19 +156,19 @@ type G13 = new ({ [2]: string }: { }) => void; interface I { method1(arg: number): any; - method2({ a }: { + method2({ a: string }: { a: any; }): any; (arg: number): any; - ({ a }: { + ({ a: string }: { a: any; }): any; new (arg: number): any; - new ({ a }: { + new ({ a: string }: { a: any; }): any; } -declare function f1({ a }: O): void; +declare function f1({ a: string }: O): void; declare const f2: ({ a: string }: O) => void; declare const f3: ({ a: string, b, c }: O) => void; declare const f4: ({ a: string }: O) => string; @@ -179,7 +179,7 @@ declare const obj1: { declare const obj2: { method({ a: string }: O): string; }; -declare function f6({ a }: O): void; +declare function f6({ a: string }: O): void; declare const f7: ({ a: string, b, c }: O) => void; declare const f8: ({ "a": string }: O) => void; declare function f9({ 2: string }: { diff --git a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js index a589fbabc4de9..d93b62dedeee6 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js @@ -111,7 +111,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection/esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection, esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, esnext.object, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index b738987321d96..37a11b54fb930 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -111,7 +111,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection/esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection, esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, esnext.object, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index b738987321d96..37a11b54fb930 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -111,7 +111,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection/esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, dom.asynciterable, webworker, webworker.importscripts, webworker.iterable, webworker.asynciterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2016.intl, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection, esnext.collection, esnext.intl, esnext.disposable, esnext.promise, esnext.decorators, esnext.object, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_namespaceSameNameAsIntrinsic.js b/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_namespaceSameNameAsIntrinsic.js index f09783085489c..5cfac18b02449 100644 --- a/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_namespaceSameNameAsIntrinsic.js +++ b/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_namespaceSameNameAsIntrinsic.js @@ -704,6 +704,12 @@ Info seq [hh:mm:ss:mss] response: "kindModifiers": "declare", "sortText": "15" }, + { + "name": "NoInfer", + "kind": "type", + "kindModifiers": "declare", + "sortText": "15" + }, { "name": "NonNullable", "kind": "type", diff --git a/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js b/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js index 4c29185d5827e..9813d58b44a80 100644 --- a/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js +++ b/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js @@ -471,7 +471,7 @@ Info seq [hh:mm:ss:mss] event: "line": 34, "offset": 16 }, - "text": "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'decorators', 'decorators.legacy'.", + "text": "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'decorators', 'decorators.legacy'.", "code": 6046, "category": "error", "fileName": "/tsconfig.json" diff --git a/tests/baselines/reference/typesVersions.ambientModules.trace.json b/tests/baselines/reference/typesVersions.ambientModules.trace.json index 637af04734a94..cc715e4c5f7b1 100644 --- a/tests/baselines/reference/typesVersions.ambientModules.trace.json +++ b/tests/baselines/reference/typesVersions.ambientModules.trace.json @@ -834,6 +834,30 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersions.emptyTypes.trace.json b/tests/baselines/reference/typesVersions.emptyTypes.trace.json index 51284d259e6a9..1860a9288d301 100644 --- a/tests/baselines/reference/typesVersions.emptyTypes.trace.json +++ b/tests/baselines/reference/typesVersions.emptyTypes.trace.json @@ -866,6 +866,32 @@ "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersions.justIndex.trace.json b/tests/baselines/reference/typesVersions.justIndex.trace.json index 567aedf61205d..c027d7ee5f121 100644 --- a/tests/baselines/reference/typesVersions.justIndex.trace.json +++ b/tests/baselines/reference/typesVersions.justIndex.trace.json @@ -866,6 +866,32 @@ "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersions.multiFile.trace.json b/tests/baselines/reference/typesVersions.multiFile.trace.json index 7f5aaf3d3ebc9..533725ea68f2d 100644 --- a/tests/baselines/reference/typesVersions.multiFile.trace.json +++ b/tests/baselines/reference/typesVersions.multiFile.trace.json @@ -813,6 +813,30 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json index 637af04734a94..cc715e4c5f7b1 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json @@ -834,6 +834,30 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json index 7f5aaf3d3ebc9..533725ea68f2d 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json @@ -813,6 +813,30 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json index 5598b74ec8099..a84c6cc085223 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json @@ -836,6 +836,30 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json index ded85860a42e3..50d0ecbeb1d53 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json @@ -819,6 +819,30 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/cases/compiler/allowJsCrossMonorepoPackage.ts b/tests/cases/compiler/allowJsCrossMonorepoPackage.ts new file mode 100644 index 0000000000000..2af955d311deb --- /dev/null +++ b/tests/cases/compiler/allowJsCrossMonorepoPackage.ts @@ -0,0 +1,44 @@ +// @Filename: /node_modules/pkg/index.d.ts +export declare function pkg(): "pkg"; + +// @Filename: /packages/shared/package.json +{ + "name": "shared", + "version": "1.0.0", + "type": "module", + "exports": "./index.js" +} + +// @Filename: /packages/shared/utils.js +export { pkg } from "pkg"; + +// @Filename: /packages/shared/index.js +import { pkg } from "./utils.js"; +export const x = pkg(); + +// @Filename: /packages/main/package.json +{ + "name": "main", + "version": "1.0.0", + "type": "module", + "dependencies": { + "shared": "workspace:*" + } +} + +// @Filename: /packages/main/tsconfig.json +{ + "compilerOptions": { + "noEmit": true, + "checkJs": true, + "strict": true, + "module": "esnext", + "moduleResolution": "bundler", + "traceResolution": true, + } +} + +// @link: /packages/shared -> /packages/main/node_modules/shared + +// @Filename: /packages/main/index.ts +import { x } from "shared"; diff --git a/tests/cases/compiler/declarationEmitBindingPatternsFunctionExpr.ts b/tests/cases/compiler/declarationEmitBindingPatternsFunctionExpr.ts new file mode 100644 index 0000000000000..42fda3d008873 --- /dev/null +++ b/tests/cases/compiler/declarationEmitBindingPatternsFunctionExpr.ts @@ -0,0 +1,18 @@ +// @declaration: true +// @target: esnext +// @skipLibCheck: false + +type Named = { name: string } +// Tempting to remove alias if unused +let notReferenced = ({ name: alias }: Named) => { } + +// Resons we can't remove aliases that are not used in the function signature: + +// 1.Causes duplicate identifier if we remove alias +const duplicateIndetifiers = ({ name: alias, name: alias2 }: Named) => { } +const duplicateIndetifiers2 = (name: string, { name: alias }: Named) => { } +const duplicateIndetifiers3 = ({ name: alias }: Named, { name: alias2 }: Named) => { } + +let value = ""; +// 2.Can change in meaning for typeof value if we remove alias +const shadowedVariable = ({ value: alias }: { value: string }): typeof value => value; \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitBindingPatternsUnused.ts b/tests/cases/compiler/declarationEmitBindingPatternsUnused.ts index 285292e8d4819..173b280cd5149 100644 --- a/tests/cases/compiler/declarationEmitBindingPatternsUnused.ts +++ b/tests/cases/compiler/declarationEmitBindingPatternsUnused.ts @@ -3,6 +3,18 @@ // @skipLibCheck: false type Named = { name: string } + +// Resons we can't remove aliases that are not used in the function signature: + +// 1.Causes duplicate identifier if we remove alias +function duplicateIndetifiers({ name: alias, name: alias2 }: Named) { } +function duplicateIndetifiers2(name: string, { name: alias }: Named) { } +function duplicateIndetifiers3({ name: alias }: Named, { name: alias2 }: Named) { } + +let value = ""; +// 2.Can change in meaning for typeof value if we remove alias +function shadowedVariable({ value: alias }: { value: string }): typeof value { return value } + function notReferenced({ name: alias }: Named) { } @@ -11,8 +23,6 @@ function notReferencedNestedAlias({ p: { name: alias } }: { p: Named }) { function notReferencedArrayAlias([a, b, { name: alias }]: Named[]) { } - - function referencedInCode({ name: alias }: Named) { return alias; } diff --git a/tests/cases/compiler/declarationEmitUsingTypeAlias1.ts b/tests/cases/compiler/declarationEmitUsingTypeAlias1.ts new file mode 100644 index 0000000000000..257a82e3e32bc --- /dev/null +++ b/tests/cases/compiler/declarationEmitUsingTypeAlias1.ts @@ -0,0 +1,30 @@ +// @strict: true +// @declaration: true +// @module: nodenext + +// @filename: node_modules/some-dep/dist/inner.d.ts +export declare type Other = { other: string }; +export declare type SomeType = { arg: Other }; + +// @filename: node_modules/some-dep/dist/index.d.ts +export type OtherType = import('./inner').Other; +export type SomeType = import('./inner').SomeType; + +// @filename: node_modules/some-dep/package.json +{ + "name": "some-dep", + "exports": { + ".": "./dist/index.js" + } +} + +// @filename: src/index.ts +import { SomeType } from "some-dep"; + +export const foo = (thing: SomeType) => { + return thing; +}; + +export const bar = (thing: SomeType) => { + return thing.arg; +}; \ No newline at end of file diff --git a/tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts b/tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts new file mode 100644 index 0000000000000..2a2a69bd22e70 --- /dev/null +++ b/tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts @@ -0,0 +1,16 @@ +// @strict: true +// @checkJs: true +// @declaration: true +// @outDir: out + +// @filename: index.js + +/** + * @typedef Options + * @property {string} opt + */ + +/** + * @param {Options} options + */ +module.exports = function loader(options) {} diff --git a/tests/cases/compiler/mapGroupBy.ts b/tests/cases/compiler/mapGroupBy.ts new file mode 100644 index 0000000000000..a9fbbe9247020 --- /dev/null +++ b/tests/cases/compiler/mapGroupBy.ts @@ -0,0 +1,11 @@ +// @target: esnext + +const basic = Map.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); + +const chars = Map.groupBy('a string', c => c); + +type Employee = { name: string, role: 'ic' | 'manager' } +const employees: Set = new Set(); +const byRole = Map.groupBy(employees, x => x.role); + +const byNonKey = Map.groupBy(employees, x => x); diff --git a/tests/cases/compiler/objectGroupBy.ts b/tests/cases/compiler/objectGroupBy.ts new file mode 100644 index 0000000000000..5dd93542493f1 --- /dev/null +++ b/tests/cases/compiler/objectGroupBy.ts @@ -0,0 +1,11 @@ +// @target: esnext + +const basic = Object.groupBy([0, 2, 8], x => x < 5 ? 'small' : 'large'); + +const chars = Object.groupBy('a string', c => c); + +type Employee = { name: string, role: 'ic' | 'manager' } +const employees: Set = new Set(); +const byRole = Object.groupBy(employees, x => x.role); + +const byNonKey = Object.groupBy(employees, x => x); diff --git a/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts new file mode 100644 index 0000000000000..6183e22b61fbf --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts @@ -0,0 +1,26 @@ +// @noImplicitAny: true + +// To be inferred as `number` +function f1() { + const [a1, b1 = a1] = [1]; + const [a2, b2 = 1 + a2] = [1]; +} + +// To be inferred as `string` +function f2() { + const [a1, b1 = a1] = ['hi']; + const [a2, b2 = a2 + '!'] = ['hi']; +} + +// To be inferred as `string | number` +function f3() { + const [a1, b1 = a1] = ['hi', 1]; + const [a2, b2 = a2 + '!'] = ['hi', 1]; +} + +// Based on comment: +// - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 +declare const yadda: [number, number] | undefined +function f4() { + const [ a, b = a ] = yadda ?? []; +} diff --git a/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts new file mode 100644 index 0000000000000..d4d5cd7c6cd4d --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts @@ -0,0 +1,26 @@ +// @noImplicitAny: true + +// To be inferred as `number` +function f1() { + const { a1, b1 = a1 } = { a1: 1 }; + const { a2, b2 = 1 + a2 } = { a2: 1 }; +} + +// To be inferred as `string` +function f2() { + const { a1, b1 = a1 } = { a1: 'hi' }; + const { a2, b2 = a2 + '!' } = { a2: 'hi' }; +} + +// To be inferred as `string | number` +function f3() { + const { a1, b1 = a1 } = { a1: 'hi', b1: 1 }; + const { a2, b2 = a2 + '!' } = { a2: 'hi', b2: 1 }; +} + +// Based on comment: +// - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 +declare const yadda: { a?: number, b?: number } | undefined +function f4() { + const { a, b = a } = yadda ?? {}; +} diff --git a/tests/cases/conformance/importAttributes/importAttributes9.ts b/tests/cases/conformance/importAttributes/importAttributes9.ts new file mode 100644 index 0000000000000..9b7138659272b --- /dev/null +++ b/tests/cases/conformance/importAttributes/importAttributes9.ts @@ -0,0 +1,22 @@ +// @module: esnext +// @target: esnext +// @filename: ./a.ts +export default {}; + +// @filename: ./b.ts +declare global { + interface ImportAttributes { + type: "json" + } +} + +import * as ns from "./a" with { type: "not-json" }; +void ns; + +async function f() { + await import("./a", { + with: { + type: "not-json", + }, + }); +} diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/noInfer.ts b/tests/cases/conformance/types/typeRelationships/typeInference/noInfer.ts new file mode 100644 index 0000000000000..49b3dd087a10b --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/typeInference/noInfer.ts @@ -0,0 +1,84 @@ +// @strict: true +// @declaration: true + +// NoInfer is erased for primitives + +type T00 = NoInfer; +type T01 = NoInfer; +type T02 = NoInfer; +type T03 = NoInfer<"foo">; +type T04 = NoInfer<`foo${string}`>; +type T05 = NoInfer<`foo${string}` & `${string}bar`>; +type T06 = NoInfer<{}>; + +// NoInfer is preserved for object types + +type T10 = NoInfer; +type T11 = NoInfer<{ x: string }>; + +// NoInfer is erased if it has no effect + +type T20 = NoInfer>; +type T21 = NoInfer & string>; +type T22 = NoInfer & string[]>; + +// keyof NoInfer is transformed into NoInfer + +type T30 = keyof NoInfer<{ a: string, b: string }>; +type T31 = keyof NoInfer; +type T32 = { [K in keyof NoInfer<{ a: string, b: string }>]: K }; + +declare function foo1(a: T, b: NoInfer): void +declare function foo2(a: T, b: NoInfer[]): void +declare function foo3(a: T, b: NoInfer): void +declare function foo4(a: T, b: { x: NoInfer }): void +declare function foo5(a: T, b: NoInfer<{ x: T }>): void + +foo1('foo', 'foo') // ok +foo1('foo', 'bar') // error +foo2('foo', ['bar']) // error +foo3('foo', ['bar']) // error +foo4('foo', { x: 'bar' }) // error +foo5('foo', { x: 'bar' }) // error + +declare class Animal { move(): void } +declare class Dog extends Animal { woof(): void } +declare function doSomething(value: T, getDefault: () => NoInfer): void; + +doSomething(new Animal(), () => new Animal()); // ok +doSomething(new Animal(), () => new Dog()); // ok +doSomething(new Dog(), () => new Animal()); // error + +declare function assertEqual(actual: T, expected: NoInfer): boolean; + +assertEqual({ x: 1 }, { x: 3 }); // ok +const g = { x: 3, y: 2 }; +assertEqual(g, { x: 3 }); // error + +declare function invoke(func: (value: T) => R, value: NoInfer): R; +declare function test(value: { x: number; }): number; + +invoke(test, { x: 1, y: 2 }); // error +test({ x: 1, y: 2 }); // error + +type Component = { props: Props; }; +declare function doWork(Component: Component, props: NoInfer): void; +declare const comp: Component<{ foo: number }>; + +doWork(comp, { foo: 42 }); // ok +doWork(comp, {}); // error + +declare function mutate(callback: (a: NoInfer, b: number) => T): T; +const mutate1 = mutate((a, b) => b); + +declare class ExampleClass {} +class OkClass { + constructor(private clazz: ExampleClass, private _value: NoInfer) {} + + get value(): T { + return this._value; // ok + } +} +class OkClass2 { + constructor(private clazz: ExampleClass, public _value: NoInfer) {} +} diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts b/tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts new file mode 100644 index 0000000000000..feab4ca3df0ea --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/typeInference/noInferRedeclaration.ts @@ -0,0 +1,13 @@ +// @strict: true +// @declaration: true +// @target: esnext + +// @filename: a.ts +export const f = (x: T, y: NoInfer) => x; + +// @filename: b.ts +import { f } from "./a"; + +type NoInfer = T & number; + +export const g = f; diff --git a/tests/cases/fourslash/autoImportTypeImport1.ts b/tests/cases/fourslash/autoImportTypeImport1.ts new file mode 100644 index 0000000000000..40422df03d2e7 --- /dev/null +++ b/tests/cases/fourslash/autoImportTypeImport1.ts @@ -0,0 +1,46 @@ +/// + +// @verbatimModuleSyntax: true +// @target: esnext + +// @Filename: /foo.ts +//// export const A = 1; +//// export type B = { x: number }; +//// export type C = 1; +//// export class D = { y: string }; + +// @Filename: /test.ts +//// import { A, D, type C } from './foo'; +//// const b: B/**/ | C; +//// console.log(A, D); + +goTo.marker(""); + +// importFixes should only place the import in sorted position if the existing imports are sorted as specified, +// otherwise the import should be placed at the end +verify.importFixAtPosition([ +`import { A, D, type C, type B } from './foo'; +const b: B | C; +console.log(A, D);`], + /*errorCode*/ undefined, + { organizeImportsTypeOrder: "inline" } + // `type B` is added to the end since the existing imports are not sorted as specified +); + +verify.importFixAtPosition([ +`import { A, D, type B, type C } from './foo'; +const b: B | C; +console.log(A, D);`], + /*errorCode*/ undefined, + { organizeImportsTypeOrder: "last" } + // `type B` is added to the sorted position since the existing imports *are* sorted as specified +); + +verify.importFixAtPosition([ +`import { A, D, type C, type B } from './foo'; +const b: B | C; +console.log(A, D);`], + /*errorCode*/ undefined, + { organizeImportsTypeOrder: "first" } + // `type B` is added to the end (default behavior) since the existing imports are not sorted as specified +); \ No newline at end of file diff --git a/tests/cases/fourslash/autoImportTypeImport2.ts b/tests/cases/fourslash/autoImportTypeImport2.ts new file mode 100644 index 0000000000000..195a12980c2f8 --- /dev/null +++ b/tests/cases/fourslash/autoImportTypeImport2.ts @@ -0,0 +1,43 @@ +/// + +// @verbatimModuleSyntax: true +// @target: esnext + +// @Filename: /foo.ts +//// export const A = 1; +//// export type B = { x: number }; +//// export type C = 1; +//// export class D = { y: string }; + +// @Filename: /test.ts +//// import { A, type C, D } from './foo'; +//// const b: B/**/ | C; +//// console.log(A, D); + +goTo.marker(""); + +// importFixes should only place the import in sorted position if the existing imports are sorted as specified, +// otherwise the import should be placed at the end +verify.importFixAtPosition([ +`import { A, type B, type C, D } from './foo'; +const b: B | C; +console.log(A, D);`], + /*errorCode*/ undefined, + { organizeImportsTypeOrder: "inline" } +); + +verify.importFixAtPosition([ +`import { A, type C, D, type B } from './foo'; +const b: B | C; +console.log(A, D);`], + /*errorCode*/ undefined, + { organizeImportsTypeOrder: "last" } +); + +verify.importFixAtPosition([ +`import { A, type C, D, type B } from './foo'; +const b: B | C; +console.log(A, D);`], + /*errorCode*/ undefined, + { organizeImportsTypeOrder: "first" } +); \ No newline at end of file diff --git a/tests/cases/fourslash/autoImportTypeImport3.ts b/tests/cases/fourslash/autoImportTypeImport3.ts new file mode 100644 index 0000000000000..50594e625817c --- /dev/null +++ b/tests/cases/fourslash/autoImportTypeImport3.ts @@ -0,0 +1,44 @@ +/// + +// @verbatimModuleSyntax: true +// @target: esnext + +// @Filename: /foo.ts +//// export const A = 1; +//// export type B = { x: number }; +//// export type C = 1; +//// export class D = { y: string }; + +// @Filename: /test.ts +//// import { A, type B, type C } from './foo'; +//// const b: B | C; +//// console.log(A, D/**/); + +goTo.marker(""); + +// importFixes should only place the import in sorted position if the existing imports are sorted as specified, +// otherwise the import should be placed at the end (regardless of if it's a regular or type-only import) +verify.importFixAtPosition([ +`import { A, D, type B, type C } from './foo'; +const b: B | C; +console.log(A, D);`], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" } +); + +verify.importFixAtPosition([ +`import { A, type B, type C, D } from './foo'; +const b: B | C; +console.log(A, D);`], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "inline" } +); + +verify.importFixAtPosition([ +`import { A, type B, type C, D } from './foo'; +const b: B | C; +console.log(A, D);`], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "first" } + // `D` is added to the end since `A, type B, type C` is not sorted to "first" +); \ No newline at end of file diff --git a/tests/cases/fourslash/autoImportTypeImport4.ts b/tests/cases/fourslash/autoImportTypeImport4.ts new file mode 100644 index 0000000000000..82dff821438f7 --- /dev/null +++ b/tests/cases/fourslash/autoImportTypeImport4.ts @@ -0,0 +1,111 @@ +/// + +// @verbatimModuleSyntax: true +// @target: esnext + +// @Filename: /exports1.ts +//// export const a = 0; +//// export const A = 1; +//// export const b = 2; +//// export const B = 3; +//// export const c = 4; +//// export const C = 5; +//// export type x = 6; +//// export const X = 7; +//// export const Y = 8; +//// export const Z = 9; + +// @Filename: /exports2.ts +//// export const d = 0; +//// export const D = 1; +//// export const e = 2; +//// export const E = 3; + +// @Filename: /index0.ts +//// import { A, B, C } from "./exports1"; +//// a/*0*/; +//// b; + +// @Filename: /index1.ts +//// import { A, B, C, type Y, type Z } from "./exports1"; +//// a/*1*/; +//// b; + +// @Filename: /index2.ts +//// import { A, a, B, b, type Y, type Z } from "./exports1"; +//// import { E } from "./exports2"; +//// d/*2*/ + +// addition of correctly sorted type imports should not affect behavior as shown in autoImportSortCaseSensitivity1.ts +goTo.marker("0"); +verify.importFixAtPosition([ + `import { A, B, C, a } from "./exports1";\na;\nb;`, + `import { A, B, C, b } from "./exports1";\na;\nb;`, +], + /*errorCode*/ undefined, + { organizeImportsTypeOrder : "last" }); +verify.importFixAtPosition([ + `import { a, A, B, C } from "./exports1";\na;\nb;`, + `import { A, b, B, C } from "./exports1";\na;\nb;` +], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" }); + +goTo.marker("1"); +verify.importFixAtPosition([ + `import { A, B, C, a, type Y, type Z } from "./exports1";\na;\nb;`, + `import { A, B, C, b, type Y, type Z } from "./exports1";\na;\nb;`, +], + /*errorCode*/ undefined, + { organizeImportsTypeOrder : "last" }); +verify.importFixAtPosition([ + `import { a, A, B, C, type Y, type Z } from "./exports1";\na;\nb;`, + `import { A, b, B, C, type Y, type Z } from "./exports1";\na;\nb;` +], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" }); + +// if we sort inline and sensitive, then all upper case imports should be sorted before any lower case imports +verify.importFixAtPosition([ + `import { A, B, C, type Y, type Z, a } from "./exports1";\na;\nb;`, + `import { A, B, C, type Y, type Z, b } from "./exports1";\na;\nb;`, +], + /*errorCode*/ undefined, + { organizeImportsTypeOrder : "inline" }); +verify.importFixAtPosition([ + `import { a, A, B, C, type Y, type Z } from "./exports1";\na;\nb;`, + `import { A, b, B, C, type Y, type Z } from "./exports1";\na;\nb;` +], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "inline" }); + +goTo.marker("2"); +verify.importFixAtPosition([ +`import { A, a, B, b, type Y, type Z } from "./exports1"; +import { d, E } from "./exports2"; +d`, +], + /*errorCode*/ undefined, + { organizeImportsTypeOrder : "last" }); +verify.importFixAtPosition([ +`import { A, a, B, b, type Y, type Z } from "./exports1"; +import { E, d } from "./exports2"; +d` +], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: false, organizeImportsTypeOrder : "last" }); + +verify.importFixAtPosition([ +`import { A, a, B, b, type Y, type Z } from "./exports1"; +import { d, E } from "./exports2"; +d`, +], + /*errorCode*/ undefined, + { organizeImportsTypeOrder : "last" }); +verify.importFixAtPosition([ +`import { A, a, B, b, type Y, type Z } from "./exports1"; +import { E, d } from "./exports2"; +d` +], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: false, organizeImportsTypeOrder : "last" }); \ No newline at end of file diff --git a/tests/cases/fourslash/autoImportTypeImport5.ts b/tests/cases/fourslash/autoImportTypeImport5.ts new file mode 100644 index 0000000000000..a0800d3f236f0 --- /dev/null +++ b/tests/cases/fourslash/autoImportTypeImport5.ts @@ -0,0 +1,86 @@ +/// + +// @verbatimModuleSyntax: true +// @target: esnext + +// @Filename: /exports1.ts +//// export const a = 0; +//// export const A = 1; +//// export const b = 2; +//// export const B = 3; +//// export const c = 4; +//// export const C = 5; +//// export type x = 6; +//// export const X = 7; +//// export type y = 8 +//// export const Y = 9; +//// export const Z = 10; + +// @Filename: /exports2.ts +//// export const d = 0; +//// export const D = 1; +//// export const e = 2; +//// export const E = 3; + +// @Filename: /index0.ts +//// import { type X, type Y, type Z } from "./exports1"; +//// const foo: x/*0*/; +//// const bar: y; + +// @Filename: /index1.ts +//// import { A, B, type X, type Y, type Z } from "./exports1"; +//// const foo: x/*1*/; +//// const bar: y; + +// addition of correctly sorted regular imports should not affect correctly sorted type imports +goTo.marker("0"); +verify.importFixAtPosition([ + `import { type X, type Y, type Z, type x } from "./exports1";\nconst foo: x;\nconst bar: y;`, + `import { type X, type Y, type Z, type y } from "./exports1";\nconst foo: x;\nconst bar: y;`, +], + /*errorCode*/ undefined, + { organizeImportsTypeOrder : "last" }); +verify.importFixAtPosition([ + `import { type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, + `import { type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, +], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" }); +verify.importFixAtPosition([ + `import { type X, type Y, type Z, type x } from "./exports1";\nconst foo: x;\nconst bar: y;`, + `import { type X, type Y, type Z, type y } from "./exports1";\nconst foo: x;\nconst bar: y;`, +], + /*errorCode*/ undefined, + { organizeImportsTypeOrder : "inline" }); +verify.importFixAtPosition([ + `import { type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, + `import { type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, +], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "inline" }); +verify.importFixAtPosition([ + `import { type X, type Y, type Z, type x } from "./exports1";\nconst foo: x;\nconst bar: y;`, + `import { type X, type Y, type Z, type y } from "./exports1";\nconst foo: x;\nconst bar: y;`, +], + /*errorCode*/ undefined, + { organizeImportsTypeOrder : "first" }); +verify.importFixAtPosition([ + `import { type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, + `import { type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, +], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "first" }); + +goTo.marker("1"); +verify.importFixAtPosition([ + `import { A, B, type X, type Y, type Z, type x } from "./exports1";\nconst foo: x;\nconst bar: y;`, + `import { A, B, type X, type Y, type Z, type y } from "./exports1";\nconst foo: x;\nconst bar: y;`, +], + /*errorCode*/ undefined, + { organizeImportsTypeOrder : "last" }); +verify.importFixAtPosition([ + `import { A, B, type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, + `import { A, B, type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, +], + /*errorCode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" }); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListForImportAttributes.ts b/tests/cases/fourslash/completionListForImportAttributes.ts new file mode 100644 index 0000000000000..f96c4c9d27f3a --- /dev/null +++ b/tests/cases/fourslash/completionListForImportAttributes.ts @@ -0,0 +1,22 @@ +/// + +// @module: esnext +// @target: esnext +// @filename: ./a.ts +////export default {}; + +// @filename: ./b.ts +////declare global { +//// interface ImportAttributes { +//// type: "json", +//// "resolution-mode": "import" +//// } +////} +////const str = "hello"; +//// +////import * as t1 from "./a" with { /*1*/ }; +////import * as t2 from "./a" with { type: "/*2*/" }; +////import * as t3 from "./a" with { type: "json", /*3*/ }; +////import * as t4 from "./a" with { type: /*4*/ }; + +verify.baselineCompletions(); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index b61f947e488b1..5daa7c0b3167e 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -670,6 +670,7 @@ declare namespace FourSlashInterface { readonly organizeImportsNumericCollation?: boolean; readonly organizeImportsAccentCollation?: boolean; readonly organizeImportsCaseFirst?: "upper" | "lower" | false; + readonly organizeImportsTypeOrder?: "first" | "last" | "inline"; } interface InlayHintsOptions extends UserPreferences { readonly includeInlayParameterNameHints?: "none" | "literals" | "all"; diff --git a/tests/cases/fourslash/goToDefinitionSwitchCase1.ts b/tests/cases/fourslash/goToDefinitionSwitchCase1.ts new file mode 100644 index 0000000000000..86a695f1ecf3b --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionSwitchCase1.ts @@ -0,0 +1,7 @@ +/// + +////switch (null ) { +//// [|/*start*/case|] null: break; +////} + +verify.baselineGoToDefinition("start"); diff --git a/tests/cases/fourslash/goToDefinitionSwitchCase2.ts b/tests/cases/fourslash/goToDefinitionSwitchCase2.ts new file mode 100644 index 0000000000000..3d480dd198afb --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionSwitchCase2.ts @@ -0,0 +1,7 @@ +/// + +////switch (null) { +//// [|/*start*/default|]: break; +////} + +verify.baselineGoToDefinition("start"); diff --git a/tests/cases/fourslash/goToDefinitionSwitchCase3.ts b/tests/cases/fourslash/goToDefinitionSwitchCase3.ts new file mode 100644 index 0000000000000..0dce0e7c153fc --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionSwitchCase3.ts @@ -0,0 +1,11 @@ +/// + +////switch (null) { +//// [|/*start1*/default|]: { +//// switch (null) { +//// [|/*start2*/default|]: break; +//// } +//// }; +////} + +verify.baselineGoToDefinition("start1", "start2"); diff --git a/tests/cases/fourslash/goToDefinitionSwitchCase4.ts b/tests/cases/fourslash/goToDefinitionSwitchCase4.ts new file mode 100644 index 0000000000000..db4b801415dc2 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionSwitchCase4.ts @@ -0,0 +1,11 @@ +/// + +//// switch (null) { +//// case null: break; +//// } +//// +//// switch (null) { +//// [|/*start*/case|] null: break; +//// } + +verify.baselineGoToDefinition("start"); diff --git a/tests/cases/fourslash/goToDefinitionSwitchCase5.ts b/tests/cases/fourslash/goToDefinitionSwitchCase5.ts new file mode 100644 index 0000000000000..83e8f28ad0aab --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionSwitchCase5.ts @@ -0,0 +1,5 @@ +/// + +////export [|/*start*/default|] {} + +verify.baselineGoToDefinition("start"); diff --git a/tests/cases/fourslash/goToDefinitionSwitchCase6.ts b/tests/cases/fourslash/goToDefinitionSwitchCase6.ts new file mode 100644 index 0000000000000..b6ac5daf8f5f8 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionSwitchCase6.ts @@ -0,0 +1,7 @@ +/// + +////export default { [|/*a*/case|] }; +////[|/*b*/default|]; +////[|/*c*/case|] 42; + +verify.baselineGoToDefinition("a", "b", "c"); diff --git a/tests/cases/fourslash/goToDefinitionSwitchCase7.ts b/tests/cases/fourslash/goToDefinitionSwitchCase7.ts new file mode 100644 index 0000000000000..244b4b0b6a726 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionSwitchCase7.ts @@ -0,0 +1,7 @@ +/// + +////switch (null) { +//// case null: +//// export [|/*start*/default|] 123; + +verify.baselineGoToDefinition("start"); diff --git a/tests/cases/fourslash/importNameCodeFix_importType7.ts b/tests/cases/fourslash/importNameCodeFix_importType7.ts index 7d28f3019654b..c74a3c2c22837 100644 --- a/tests/cases/fourslash/importNameCodeFix_importType7.ts +++ b/tests/cases/fourslash/importNameCodeFix_importType7.ts @@ -22,3 +22,31 @@ verify.importFixAtPosition([ type SomeInterface, } from "./exports.js"; new SomePig`]); + +verify.importFixAtPosition([ +`import { + SomePig, + type SomeInterface, +} from "./exports.js"; +new SomePig`], +/*errorCode*/ undefined, +{ organizeImportsTypeOrder: "last" }); + +verify.importFixAtPosition([ +`import { + type SomeInterface, + SomePig, +} from "./exports.js"; +new SomePig`], + /*errorCode*/ undefined, + { organizeImportsTypeOrder: "inline" } +); + +verify.importFixAtPosition([ +`import { + type SomeInterface, + SomePig, +} from "./exports.js"; +new SomePig`], +/*errorCode*/ undefined, +{ organizeImportsTypeOrder: "first" }); diff --git a/tests/cases/fourslash/organizeImports1.ts b/tests/cases/fourslash/organizeImports1.ts index 58306c8161caa..53ee2c25b1fe1 100644 --- a/tests/cases/fourslash/organizeImports1.ts +++ b/tests/cases/fourslash/organizeImports1.ts @@ -18,26 +18,26 @@ //// console.log(a, B, b, c, C, d, D); //// console.log(e, f, F, g, G, H, h); -// verify.organizeImports( -// `import { -// a, -// b, -// b as B, -// c, -// c as C, -// d, d as D, -// e, -// f, -// f as F, -// g, -// g as G, -// h, h as H -// } from './foo'; +verify.organizeImports( +`import { + a, + b, + b as B, + c, + c as C, + d, d as D, + e, + f, + f as F, + g, + g as G, + h, h as H +} from './foo'; -// console.log(a, B, b, c, C, d, D); -// console.log(e, f, F, g, G, H, h);`, -// /*mode*/ undefined, -// { organizeImportsIgnoreCase: true }); +console.log(a, B, b, c, C, d, D); +console.log(e, f, F, g, G, H, h);`, +/*mode*/ undefined, +{ organizeImportsIgnoreCase: true }); verify.organizeImports( `import { diff --git a/tests/cases/fourslash/organizeImports16.ts b/tests/cases/fourslash/organizeImports16.ts index 93aa5a81f2cb8..be7150c047e0f 100644 --- a/tests/cases/fourslash/organizeImports16.ts +++ b/tests/cases/fourslash/organizeImports16.ts @@ -9,22 +9,25 @@ verify.organizeImports( interface Use extends A {} console.log(a, b);`); +edit.replaceLine(0, 'import { a, A, b } from "foo1";'); verify.organizeImports( -`import { a, A, b } from "foo"; +`import { a, A, b } from "foo1"; interface Use extends A {} console.log(a, b);`, /*mode*/ undefined, { organizeImportsIgnoreCase: "auto" }); +edit.replaceLine(0, 'import { a, A, b } from "foo2";'); verify.organizeImports( -`import { a, A, b } from "foo"; +`import { a, A, b } from "foo2"; interface Use extends A {} console.log(a, b);`, /*mode*/ undefined, { organizeImportsIgnoreCase: true }); +edit.replaceLine(0, 'import { a, A, b } from "foo3";'); verify.organizeImports( -`import { A, a, b } from "foo"; +`import { A, a, b } from "foo3"; interface Use extends A {} console.log(a, b);`, /*mode*/ undefined, diff --git a/tests/cases/fourslash/organizeImportsType1.ts b/tests/cases/fourslash/organizeImportsType1.ts new file mode 100644 index 0000000000000..998cb2f041123 --- /dev/null +++ b/tests/cases/fourslash/organizeImportsType1.ts @@ -0,0 +1,46 @@ +/// + +// @allowSyntheticDefaultImports: true +// @moduleResolution: node +// @noUnusedLocals: true +// @target: es2018 + +//// import { A } from "foo"; +//// import { type B } from "foo"; +//// import { C } from "foo"; +//// import { type E } from "foo"; +//// import { D } from "foo"; +//// +//// console.log(A, B, C, D, E); + +// default behavior is "last" +verify.organizeImports( +`import { A, C, D, type B, type E } from "foo"; + +console.log(A, B, C, D, E);` +); + +verify.organizeImports( +`import { A, type B, C, D, type E } from "foo"; + +console.log(A, B, C, D, E);`, + undefined, + { organizeImportsTypeOrder : "inline" } +); + + +verify.organizeImports( +`import { type B, type E, A, C, D } from "foo"; + +console.log(A, B, C, D, E);`, + undefined, + { organizeImportsTypeOrder : "first" } +); + +verify.organizeImports( +`import { A, C, D, type B, type E } from "foo"; + +console.log(A, B, C, D, E);`, + undefined, + { organizeImportsTypeOrder : "last" } +); \ No newline at end of file diff --git a/tests/cases/fourslash/organizeImportsType2.ts b/tests/cases/fourslash/organizeImportsType2.ts new file mode 100644 index 0000000000000..57b2b4db26950 --- /dev/null +++ b/tests/cases/fourslash/organizeImportsType2.ts @@ -0,0 +1,50 @@ +/// + +// @allowSyntheticDefaultImports: true +// @moduleResolution: node +// @noUnusedLocals: true +// @target: es2018 + +//// type A = string; +//// type B = string; +//// const C = "hello"; +//// export { A, type B, C }; + +// default behavior is equivalent to "last" +verify.organizeImports( +`type A = string; +type B = string; +const C = "hello"; +export { A, C, type B }; +` +); + +verify.organizeImports( +`type A = string; +type B = string; +const C = "hello"; +export { A, type B, C }; +`, + undefined, + { organizeImportsTypeOrder : "inline" } +); + +verify.organizeImports( +`type A = string; +type B = string; +const C = "hello"; +export { type B, A, C }; +`, + undefined, + { organizeImportsTypeOrder : "first" } +); + +verify.organizeImports( +`type A = string; +type B = string; +const C = "hello"; +export { A, C, type B }; +`, + undefined, + { organizeImportsTypeOrder : "last" } +); \ No newline at end of file diff --git a/tests/cases/fourslash/organizeImportsType3.ts b/tests/cases/fourslash/organizeImportsType3.ts new file mode 100644 index 0000000000000..4ed9a24f04cb5 --- /dev/null +++ b/tests/cases/fourslash/organizeImportsType3.ts @@ -0,0 +1,29 @@ +/// + +//// import { +//// d, +//// type d as D, +//// type c, +//// c as C, +//// b, +//// b as B, +//// type A, +//// a +//// } from './foo'; +//// console.log(A, a, B, b, c, C, d, D); + +verify.organizeImports( +`import { + type A, + b as B, + c as C, + type d as D, + a, + b, + type c, + d +} from './foo'; +console.log(A, a, B, b, c, C, d, D);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: false, organizeImportsTypeOrder: "inline" } +); diff --git a/tests/cases/fourslash/organizeImportsType4.ts b/tests/cases/fourslash/organizeImportsType4.ts new file mode 100644 index 0000000000000..da76b5f17bbea --- /dev/null +++ b/tests/cases/fourslash/organizeImportsType4.ts @@ -0,0 +1,29 @@ +/// + +//// import { +//// d, +//// type d as D, +//// type c, +//// c as C, +//// b, +//// b as B, +//// type A, +//// a +//// } from './foo'; +//// console.log(A, a, B, b, c, C, d, D); + +verify.organizeImports( +`import { + type A, + a, + b, + b as B, + type c, + c as C, + d, + type d as D +} from './foo'; +console.log(A, a, B, b, c, C, d, D);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder: "inline" } +); diff --git a/tests/cases/fourslash/organizeImportsType5.ts b/tests/cases/fourslash/organizeImportsType5.ts new file mode 100644 index 0000000000000..1f8bb8dd602a7 --- /dev/null +++ b/tests/cases/fourslash/organizeImportsType5.ts @@ -0,0 +1,29 @@ +/// + +//// import { +//// d, +//// type d as D, +//// type c, +//// c as C, +//// b, +//// b as B, +//// type A, +//// a +//// } from './foo'; +//// console.log(A, a, B, b, c, C, d, D); + +verify.organizeImports( +`import { + type A, + b as B, + c as C, + type d as D, + a, + b, + type c, + d +} from './foo'; +console.log(A, a, B, b, c, C, d, D);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" } +); diff --git a/tests/cases/fourslash/organizeImportsType6.ts b/tests/cases/fourslash/organizeImportsType6.ts new file mode 100644 index 0000000000000..c38fc504e07b1 --- /dev/null +++ b/tests/cases/fourslash/organizeImportsType6.ts @@ -0,0 +1,36 @@ +/// + +//// import { type a, A, b } from "foo"; +//// interface Use extends A {} +//// console.log(a, b); + +verify.organizeImports( +`import { type a, A, b } from "foo"; +interface Use extends A {} +console.log(a, b);`, + /*mode*/ undefined, + { organizeImportsTypeOrder: "inline" }); + +edit.replaceLine(0, 'import { type a, A, b } from "foo1";'); +verify.organizeImports( +`import { type a, A, b } from "foo1"; +interface Use extends A {} +console.log(a, b);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" }); + +edit.replaceLine(0, 'import { type a, A, b } from "foo2";'); +verify.organizeImports( +`import { type a, A, b } from "foo2"; +interface Use extends A {} +console.log(a, b);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder: "inline" }); + +edit.replaceLine(0, 'import { type a, A, b } from "foo3";'); +verify.organizeImports( +`import { A, type a, b } from "foo3"; +interface Use extends A {} +console.log(a, b);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: false, organizeImportsTypeOrder: "inline" }); \ No newline at end of file diff --git a/tests/cases/fourslash/organizeImportsType7.ts b/tests/cases/fourslash/organizeImportsType7.ts new file mode 100644 index 0000000000000..72fd2af92c9db --- /dev/null +++ b/tests/cases/fourslash/organizeImportsType7.ts @@ -0,0 +1,36 @@ +/// + +//// import { a, type A, b } from "foo"; +//// interface Use extends A {} +//// console.log(a, b); + +verify.organizeImports( +`import { a, type A, b } from "foo"; +interface Use extends A {} +console.log(a, b);`, + /*mode*/ undefined, + { organizeImportsTypeOrder: "inline" }); + +edit.replaceLine(0, 'import { a, type A, b } from "foo1";'); +verify.organizeImports( +`import { a, type A, b } from "foo1"; +interface Use extends A {} +console.log(a, b);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" }); + +edit.replaceLine(0, 'import { a, type A, b } from "foo2";'); +verify.organizeImports( +`import { a, type A, b } from "foo2"; +interface Use extends A {} +console.log(a, b);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: true, organizeImportsTypeOrder: "inline"}); + +edit.replaceLine(0, 'import { a, type A, b } from "foo3";'); +verify.organizeImports( +`import { type A, a, b } from "foo3"; +interface Use extends A {} +console.log(a, b);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: false, organizeImportsTypeOrder: "inline" }); \ No newline at end of file diff --git a/tests/cases/fourslash/organizeImportsType8.ts b/tests/cases/fourslash/organizeImportsType8.ts new file mode 100644 index 0000000000000..da43f893431df --- /dev/null +++ b/tests/cases/fourslash/organizeImportsType8.ts @@ -0,0 +1,53 @@ +/// + +//// import { type A, type a, b, B } from "foo"; +//// console.log(a, b, A, B); + +verify.organizeImports( +`import { type A, type a, b, B } from "foo"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" } +); + +edit.replaceLine(0, 'import { type A, type a, b, B } from "foo1";'); +verify.organizeImports( +`import { type A, type a, b, B } from "foo1"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "first" } +); + +edit.replaceLine(0, 'import { type A, type a, b, B } from "foo2";'); +verify.organizeImports( +`import { B, b, type A, type a } from "foo2"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "last" } +); + +// default behavior is { organizeImportsTypeOrder: "last" } + +edit.replaceLine(0, 'import { type A, type a, b, B } from "foo3";'); +verify.organizeImports( +`import { B, b, type A, type a } from "foo3"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto" } +); + +edit.replaceLine(0, 'import { type A, type a, b, B } from "foo4";'); +verify.organizeImports( +`import { b, B, type A, type a } from "foo4"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: true } +); + +edit.replaceLine(0, 'import { type A, type a, b, B } from "foo5";'); +verify.organizeImports( +`import { B, b, type A, type a } from "foo5"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: false } +); \ No newline at end of file diff --git a/tests/cases/fourslash/organizeImportsType9.ts b/tests/cases/fourslash/organizeImportsType9.ts new file mode 100644 index 0000000000000..efe6107e020b6 --- /dev/null +++ b/tests/cases/fourslash/organizeImportsType9.ts @@ -0,0 +1,48 @@ +/// + +//// import { type a, type A, b, B } from "foo"; +//// console.log(a, b, A, B); + +verify.organizeImports( +`import { type a, type A, b, B } from "foo"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" }); + +edit.replaceLine(0, 'import { type a, type A, b, B } from "foo1";'); +verify.organizeImports( +`import { type a, type A, b, B } from "foo1"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "first"} +); + +edit.replaceLine(0, 'import { type a, type A, b, B } from "foo2";'); +verify.organizeImports( +`import { B, b, type A, type a } from "foo2"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "last" } +); + +edit.replaceLine(0, 'import { type a, type A, b, B } from "foo3";'); +verify.organizeImports( +`import { B, b, type A, type a } from "foo3"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: "auto" } +); + +edit.replaceLine(0, 'import { type a, type A, b, B } from "foo4";'); +verify.organizeImports( +`import { b, B, type a, type A } from "foo4"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: true }); + +edit.replaceLine(0, 'import { type a, type A, b, B } from "foo5";'); +verify.organizeImports( +`import { B, b, type A, type a } from "foo5"; +console.log(a, b, A, B);`, + /*mode*/ undefined, + { organizeImportsIgnoreCase: false }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoJsDocTags15.ts b/tests/cases/fourslash/quickInfoJsDocTags15.ts new file mode 100644 index 0000000000000..aa611224d8e89 --- /dev/null +++ b/tests/cases/fourslash/quickInfoJsDocTags15.ts @@ -0,0 +1,36 @@ +/// + +// @allowJs: true +// @checkJs: true +// @filename: /a.js +/////** +//// * @callback Bar +//// * @param {string} name +//// * @returns {string} +//// */ +//// +/////** +//// * @typedef Foo +//// * @property {Bar} getName +//// */ +////export const foo = 1; + +// @filename: /b.js +////import * as _a from "./a.js"; +/////** +//// * @implements {_a.Foo/*1*/} +//// */ +////class C1 { } +//// +/////** +//// * @extends {_a.Foo/*2*/} +//// */ +////class C2 { } +//// +/////** +//// * @augments {_a.Foo/*3*/} +//// */ +////class C3 { } + +goTo.file("/b.js") +verify.baselineQuickInfo();