From 0603e72c4a34eab984aa162f980b95e38c79bf44 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 9 Oct 2023 13:46:24 -0700 Subject: [PATCH 1/2] Reuse more input nodes when they contain local type parameter references --- src/compiler/checker.ts | 12 ++--- .../assignmentCompatWithCallSignatures3.types | 2 +- .../assignmentCompatWithCallSignatures4.types | 4 +- .../assignmentCompatWithCallSignatures5.types | 12 ++--- .../assignmentCompatWithCallSignatures6.types | 10 ++-- ...gnmentCompatWithConstructSignatures3.types | 2 +- ...gnmentCompatWithConstructSignatures4.types | 4 +- ...gnmentCompatWithConstructSignatures5.types | 12 ++--- ...gnmentCompatWithConstructSignatures6.types | 10 ++-- tests/baselines/reference/callChain.3.types | 2 +- ...SignatureAssignabilityInInheritance2.types | 2 +- ...SignatureAssignabilityInInheritance3.types | 4 +- ...SignatureAssignabilityInInheritance4.types | 12 ++--- ...SignatureAssignabilityInInheritance5.types | 2 +- ...SignatureAssignabilityInInheritance6.types | 8 +-- .../circularInstantiationExpression.types | 2 +- .../conditionalTypeDoesntSpinForever.types | 6 +-- .../baselines/reference/conditionalTypes1.js | 2 +- .../reference/conditionalTypes1.types | 4 +- .../conditionalTypesSimplifyWhenTrivial.types | 8 +-- ...tingDeclarationsImportFromNamespace2.types | 2 +- ...SignatureAssignabilityInInheritance2.types | 2 +- ...SignatureAssignabilityInInheritance3.types | 4 +- ...SignatureAssignabilityInInheritance4.types | 12 ++--- ...SignatureAssignabilityInInheritance5.types | 2 +- ...SignatureAssignabilityInInheritance6.types | 8 +-- tests/baselines/reference/correlatedUnions.js | 2 +- .../reference/correlatedUnions.types | 4 +- ...EmitDistributiveConditionalWithInfer.types | 2 +- ...larationEmitPrivatePromiseLikeInterface.js | 2 +- ...clarationEmitReusesLambdaParameterNodes.js | 26 ++++++++++ ...tionEmitReusesLambdaParameterNodes.symbols | 37 +++++++++++++ ...rationEmitReusesLambdaParameterNodes.types | 24 +++++++++ .../reference/genericFunctionInference1.types | 16 +++--- .../reference/genericFunctionParameters.types | 2 +- .../reference/instantiationExpressions.types | 2 +- .../intersectionTypeInference1.types | 4 +- .../jsxExcessPropsAndAssignability.types | 4 +- .../reference/keyofAndIndexedAccess.types | 4 +- .../reference/mixinClassesAnnotated.types | 4 +- .../reference/multipleInferenceContexts.types | 2 +- ...rbyIdenticalGenericLambdasAssignable.types | 4 +- .../nodeModuleReexportFromDottedPath.types | 2 +- .../nonInferrableTypePropagation2.types | 2 +- .../optionalParameterRetainsNull.types | 4 +- ...eArrowFunctionWithFunctionReturnType.types | 4 +- .../reference/recursiveClassBaseType.types | 2 +- .../subtypingWithCallSignatures2.types | 4 +- .../subtypingWithCallSignatures3.types | 8 +-- .../subtypingWithCallSignatures4.types | 36 ++++++------- .../subtypingWithConstructSignatures2.types | 2 +- .../subtypingWithConstructSignatures3.types | 4 +- .../subtypingWithConstructSignatures4.types | 24 ++++----- .../subtypingWithConstructSignatures5.types | 2 +- .../subtypingWithConstructSignatures6.types | 8 +-- .../taggedTemplatesWithTypeArguments1.types | 4 +- .../typeParametersAvailableInNestedScope3.js | 9 +++- ...eParametersAvailableInNestedScope3.symbols | 52 ++++++++++++------- ...ypeParametersAvailableInNestedScope3.types | 23 +++++--- ...clarationEmitReusesLambdaParameterNodes.ts | 12 +++++ .../typeParametersAvailableInNestedScope3.ts | 5 +- 61 files changed, 314 insertions(+), 182 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitReusesLambdaParameterNodes.js create mode 100644 tests/baselines/reference/declarationEmitReusesLambdaParameterNodes.symbols create mode 100644 tests/baselines/reference/declarationEmitReusesLambdaParameterNodes.types create mode 100644 tests/cases/compiler/declarationEmitReusesLambdaParameterNodes.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6098245cb6c67..f3ec1a6fbffeb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6620,8 +6620,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if ( context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams && - type.flags & TypeFlags.TypeParameter && - !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) + type.flags & TypeFlags.TypeParameter ) { const name = typeParameterToName(type, context); context.approximateLength += idText(name).length; @@ -7510,7 +7509,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) - && some(expandedParams) + && (some(expandedParams) || some(signature.typeParameters)) ) { // As a performance optimization, reuse the same fake scope within this chain. // This is especially needed when we are working on an excessively deep type; @@ -7534,7 +7533,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const locals = existingFakeScope?.locals ?? createSymbolTable(); let newLocals: __String[] | undefined; - for (const param of expandedParams) { + for (const param of concatenate(expandedParams, map(signature.typeParameters, p => p.symbol))) { if (!locals.has(param.escapedName)) { newLocals = append(newLocals, param.escapedName); locals.set(param.escapedName, param); @@ -8149,7 +8148,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // `i` we've used thus far, to save work later (context.typeParameterNamesByTextNextNameCount ||= new Map()).set(rawtext, i); (context.typeParameterNames ||= new Map()).set(getTypeId(type), result); - (context.typeParameterNamesByText ||= new Set()).add(rawtext); + (context.typeParameterNamesByText ||= new Set()).add(text); } return result; } @@ -8407,8 +8406,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { includePrivateSymbol?.(sym); } if (isIdentifier(node)) { - const type = getDeclaredTypeOfSymbol(sym); - const name = sym.flags & SymbolFlags.TypeParameter && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : factory.cloneNode(node); + const name = sym.flags & SymbolFlags.TypeParameter ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information return { introducesError, node: setEmitFlags(setOriginalNode(name, node), EmitFlags.NoAsciiEscaping) }; } diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.types b/tests/baselines/reference/assignmentCompatWithCallSignatures3.types index 4c11234186aff..c73ecb914c3bf 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.types +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.types @@ -355,7 +355,7 @@ b13 = a13; // ok >a13 : (x: Base[], y: Derived[]) => Derived[] var b14: (x: { a: T; b: T }) => T; ->b14 : (x: { a: T; b: T; }) => T +>b14 : (x: { a: T; b: T;}) => T >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.types b/tests/baselines/reference/assignmentCompatWithCallSignatures4.types index 9bbb6314447dc..120e649599c71 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.types +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.types @@ -224,7 +224,7 @@ module Errors { >a12 : (x: Base[], y: Derived2[]) => Derived[] var b15: (x: { a: T; b: T }) => T; ->b15 : (x: { a: T; b: T; }) => T +>b15 : (x: { a: T; b: T;}) => T >x : { a: T; b: T; } >a : T >b : T @@ -240,7 +240,7 @@ module Errors { >a15 : (x: { a: string; b: number; }) => number var b15a: (x: { a: T; b: T }) => number; ->b15a : (x: { a: T; b: T; }) => number +>b15a : (x: { a: T; b: T;}) => number >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.types b/tests/baselines/reference/assignmentCompatWithCallSignatures5.types index f28b235b0f023..58dad7eddb02e 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.types +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.types @@ -50,7 +50,7 @@ var a6: (x: (arg: T) => Derived) => T; >arg : T var a11: (x: { foo: T }, y: { foo: T; bar: T }) => Base; ->a11 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base +>a11 : (x: { foo: T;}, y: { foo: T; bar: T;}) => Base >x : { foo: T; } >foo : T >y : { foo: T; bar: T; } @@ -58,13 +58,13 @@ var a11: (x: { foo: T }, y: { foo: T; bar: T }) => Base; >bar : T var a15: (x: { a: T; b: T }) => T[]; ->a15 : (x: { a: T; b: T; }) => T[] +>a15 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T var a16: (x: { a: T; b: T }) => T[]; ->a16 : (x: { a: T; b: T; }) => T[] +>a16 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T @@ -194,7 +194,7 @@ b6 = a6; // ok >a6 : (x: (arg: T) => Derived) => T var b11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; ->b11 : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base +>b11 : (x: { foo: T;}, y: { foo: U; bar: U;}) => Base >x : { foo: T; } >foo : T >y : { foo: U; bar: U; } @@ -212,7 +212,7 @@ b11 = a11; // ok >a11 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var b15: (x: { a: U; b: V; }) => U[]; ->b15 : (x: { a: U; b: V; }) => U[] +>b15 : (x: { a: U; b: V;}) => U[] >x : { a: U; b: V; } >a : U >b : V @@ -228,7 +228,7 @@ b15 = a15; // ok >a15 : (x: { a: T; b: T; }) => T[] var b16: (x: { a: T; b: T }) => T[]; ->b16 : (x: { a: T; b: T; }) => T[] +>b16 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.types b/tests/baselines/reference/assignmentCompatWithCallSignatures6.types index 23f7daaf22374..bf438aba65cd1 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.types +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.types @@ -51,7 +51,7 @@ interface A { >arg : T a11: (x: { foo: T }, y: { foo: T; bar: T }) => Base; ->a11 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base +>a11 : (x: { foo: T;}, y: { foo: T; bar: T;}) => Base >x : { foo: T; } >foo : T >y : { foo: T; bar: T; } @@ -59,13 +59,13 @@ interface A { >bar : T a15: (x: { a: T; b: T }) => T[]; ->a15 : (x: { a: T; b: T; }) => T[] +>a15 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T a16: (x: { a: T; b: T }) => T[]; ->a16 : (x: { a: T; b: T; }) => T[] +>a16 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T @@ -167,7 +167,7 @@ b5 = x.a5; >a5 : (x: (arg: T) => U) => T var b11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; ->b11 : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base +>b11 : (x: { foo: T;}, y: { foo: U; bar: U;}) => Base >x : { foo: T; } >foo : T >y : { foo: U; bar: U; } @@ -189,7 +189,7 @@ b11 = x.a11; >a11 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var b16: (x: { a: T; b: T }) => T[]; ->b16 : (x: { a: T; b: T; }) => T[] +>b16 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.types b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.types index beeb022033c73..8bf8a3a79f3d8 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.types +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.types @@ -355,7 +355,7 @@ b13 = a13; // ok >a13 : new (x: Base[], y: Derived[]) => Derived[] var b14: new (x: { a: T; b: T }) => T; ->b14 : new (x: { a: T; b: T; }) => T +>b14 : new (x: { a: T; b: T;}) => T >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.types b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.types index 5e3a05a1329fe..432520ff1e4dd 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.types +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.types @@ -224,7 +224,7 @@ module Errors { >a12 : new (x: Base[], y: Derived2[]) => Derived[] var b15: new (x: { a: T; b: T }) => T; ->b15 : new (x: { a: T; b: T; }) => T +>b15 : new (x: { a: T; b: T;}) => T >x : { a: T; b: T; } >a : T >b : T @@ -240,7 +240,7 @@ module Errors { >a15 : new (x: { a: string; b: number; }) => number var b15a: new (x: { a: T; b: T }) => number; ->b15a : new (x: { a: T; b: T; }) => number +>b15a : new (x: { a: T; b: T;}) => number >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.types b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.types index 0375aa5e31e92..01abb073ee261 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.types +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.types @@ -50,7 +50,7 @@ var a6: new (x: new (arg: T) => Derived) => T; >arg : T var a11: new (x: { foo: T }, y: { foo: T; bar: T }) => Base; ->a11 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base +>a11 : new (x: { foo: T;}, y: { foo: T; bar: T;}) => Base >x : { foo: T; } >foo : T >y : { foo: T; bar: T; } @@ -58,13 +58,13 @@ var a11: new (x: { foo: T }, y: { foo: T; bar: T }) => Base; >bar : T var a15: new (x: { a: T; b: T }) => T[]; ->a15 : new (x: { a: T; b: T; }) => T[] +>a15 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T var a16: new (x: { a: T; b: T }) => T[]; ->a16 : new (x: { a: T; b: T; }) => T[] +>a16 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T @@ -194,7 +194,7 @@ b6 = a6; // ok >a6 : new (x: new (arg: T) => Derived) => T var b11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; ->b11 : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base +>b11 : new (x: { foo: T;}, y: { foo: U; bar: U;}) => Base >x : { foo: T; } >foo : T >y : { foo: U; bar: U; } @@ -212,7 +212,7 @@ b11 = a11; // ok >a11 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var b15: new (x: { a: U; b: V; }) => U[]; ->b15 : new (x: { a: U; b: V; }) => U[] +>b15 : new (x: { a: U; b: V;}) => U[] >x : { a: U; b: V; } >a : U >b : V @@ -228,7 +228,7 @@ b15 = a15; // ok >a15 : new (x: { a: T; b: T; }) => T[] var b16: new (x: { a: T; b: T }) => T[]; ->b16 : new (x: { a: T; b: T; }) => T[] +>b16 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.types b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.types index 5c1b806659a56..34d3518a3b1d3 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.types +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.types @@ -51,7 +51,7 @@ interface A { >arg : T a11: new (x: { foo: T }, y: { foo: T; bar: T }) => Base; ->a11 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base +>a11 : new (x: { foo: T;}, y: { foo: T; bar: T;}) => Base >x : { foo: T; } >foo : T >y : { foo: T; bar: T; } @@ -59,13 +59,13 @@ interface A { >bar : T a15: new (x: { a: T; b: T }) => T[]; ->a15 : new (x: { a: T; b: T; }) => T[] +>a15 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T a16: new (x: { a: T; b: T }) => T[]; ->a16 : new (x: { a: T; b: T; }) => T[] +>a16 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T @@ -167,7 +167,7 @@ b5 = x.a5; >a5 : new (x: (arg: T) => U) => T var b11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; ->b11 : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base +>b11 : new (x: { foo: T;}, y: { foo: U; bar: U;}) => Base >x : { foo: T; } >foo : T >y : { foo: U; bar: U; } @@ -189,7 +189,7 @@ b11 = x.a11; >a11 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var b16: new (x: { a: T; b: T }) => T[]; ->b16 : new (x: { a: T; b: T; }) => T[] +>b16 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/callChain.3.types b/tests/baselines/reference/callChain.3.types index 04b3c2d02032d..feee4365c3f6a 100644 --- a/tests/baselines/reference/callChain.3.types +++ b/tests/baselines/reference/callChain.3.types @@ -5,7 +5,7 @@ declare function absorb(): T; >absorb : () => T declare const a: { m?(obj: {x: T}): T } | undefined; ->a : { m?(obj: { x: T; }): T; } | undefined +>a : { m?(obj: { x: T;}): T; } | undefined >m : ((obj: { x: T;}) => T) | undefined >obj : { x: T; } >x : T diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types index e663dd090d028..3e0c95356ae27 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types @@ -233,7 +233,7 @@ interface I extends A { >y : T a14: (x: { a: T; b: U }) => T; // ok ->a14 : (x: { a: T; b: U; }) => T +>a14 : (x: { a: T; b: U;}) => T >x : { a: T; b: U; } >a : T >b : U diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.types index b07e8757cddbf..d4ffdcc075756 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.types @@ -185,7 +185,7 @@ module Errors { interface I6 extends A { a15: (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type ->a15 : (x: { a: T; b: T; }) => T +>a15 : (x: { a: T; b: T;}) => T >x : { a: T; b: T; } >a : T >b : T @@ -193,7 +193,7 @@ module Errors { interface I7 extends A { a15: (x: { a: T; b: T }) => number; // error, T defaults to Base, which is not compatible with number or string ->a15 : (x: { a: T; b: T; }) => number +>a15 : (x: { a: T; b: T;}) => number >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.types index 55191a346a4a8..629eddc2265dd 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.types @@ -52,7 +52,7 @@ interface A { // T >arg : T a11: (x: { foo: T }, y: { foo: T; bar: T }) => Base; ->a11 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base +>a11 : (x: { foo: T;}, y: { foo: T; bar: T;}) => Base >x : { foo: T; } >foo : T >y : { foo: T; bar: T; } @@ -60,13 +60,13 @@ interface A { // T >bar : T a15: (x: { a: T; b: T }) => T[]; ->a15 : (x: { a: T; b: T; }) => T[] +>a15 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T a16: (x: { a: T; b: T }) => T[]; ->a16 : (x: { a: T; b: T; }) => T[] +>a16 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T @@ -140,7 +140,7 @@ interface I extends A { >arg : T a11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; // ok ->a11 : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base +>a11 : (x: { foo: T;}, y: { foo: U; bar: U;}) => Base >x : { foo: T; } >foo : T >y : { foo: U; bar: U; } @@ -148,13 +148,13 @@ interface I extends A { >bar : U a15: (x: { a: U; b: V; }) => U[]; // ok, T = U, T = V ->a15 : (x: { a: U; b: V; }) => U[] +>a15 : (x: { a: U; b: V;}) => U[] >x : { a: U; b: V; } >a : U >b : V a16: (x: { a: T; b: T }) => T[]; // ok, more general parameter type ->a16 : (x: { a: T; b: T; }) => T[] +>a16 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types index 1051543595877..bb866c1b5abb2 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types @@ -183,7 +183,7 @@ interface I extends B { >y : T a14: (x: { a: T; b: U }) => T; // ok ->a14 : (x: { a: T; b: U; }) => T +>a14 : (x: { a: T; b: U;}) => T >x : { a: T; b: U; } >a : T >b : U diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.types index 1e09a35b27e2d..ac83097c9d5d5 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.types @@ -54,7 +54,7 @@ interface A { // T >arg : T a11: (x: { foo: T }, y: { foo: T; bar: T }) => Base; ->a11 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base +>a11 : (x: { foo: T;}, y: { foo: T; bar: T;}) => Base >x : { foo: T; } >foo : T >y : { foo: T; bar: T; } @@ -62,13 +62,13 @@ interface A { // T >bar : T a15: (x: { a: T; b: T }) => T[]; ->a15 : (x: { a: T; b: T; }) => T[] +>a15 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T a16: (x: { a: T; b: T }) => T[]; ->a16 : (x: { a: T; b: T; }) => T[] +>a16 : (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T @@ -109,7 +109,7 @@ interface I5 extends A { interface I7 extends A { a11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; ->a11 : (x: { foo: T;}, y: { foo: U; bar: U; }) => Base +>a11 : (x: { foo: T;}, y: { foo: U; bar: U;}) => Base >x : { foo: T; } >foo : T >y : { foo: U; bar: U; } diff --git a/tests/baselines/reference/circularInstantiationExpression.types b/tests/baselines/reference/circularInstantiationExpression.types index 49fb9cb6cf901..65430d609db28 100644 --- a/tests/baselines/reference/circularInstantiationExpression.types +++ b/tests/baselines/reference/circularInstantiationExpression.types @@ -8,6 +8,6 @@ declare function foo(t: T): typeof foo; foo(""); >foo("") : (t: string) => any ->foo : (t: T) => (t: T) => any +>foo : (t: T) => typeof foo >"" : "" diff --git a/tests/baselines/reference/conditionalTypeDoesntSpinForever.types b/tests/baselines/reference/conditionalTypeDoesntSpinForever.types index 71522fb6f000e..92a7adcb33f38 100644 --- a/tests/baselines/reference/conditionalTypeDoesntSpinForever.types +++ b/tests/baselines/reference/conditionalTypeDoesntSpinForever.types @@ -40,7 +40,7 @@ export enum PubSubRecordIsStoredInRedisAsA { >name : any name: (t?: TYPE) => BuildPubSubRecordType ->name : (t?: TYPE) => BuildPubSubRecordType +>name : (t?: TYPE) => BuildPubSubRecordType >t : TYPE >name : TYPE } @@ -176,7 +176,7 @@ export enum PubSubRecordIsStoredInRedisAsA { >record : any identifier: >(t?: TYPE) => BuildPubSubRecordType ->identifier : >(t?: TYPE) => BuildPubSubRecordType +>identifier : >(t?: TYPE) => BuildPubSubRecordType >t : TYPE >identifier : TYPE @@ -236,7 +236,7 @@ export enum PubSubRecordIsStoredInRedisAsA { >record : any record: (t?: TYPE) => BuildPubSubRecordType ->record : (t?: TYPE) => BuildPubSubRecordType +>record : (t?: TYPE) => BuildPubSubRecordType >t : TYPE >record : TYPE } diff --git a/tests/baselines/reference/conditionalTypes1.js b/tests/baselines/reference/conditionalTypes1.js index 667c4de7c09a4..b90f9f21605cc 100644 --- a/tests/baselines/reference/conditionalTypes1.js +++ b/tests/baselines/reference/conditionalTypes1.js @@ -649,7 +649,7 @@ type Foo = T extends string ? boolean : number; type Bar = T extends string ? boolean : number; declare const convert: (value: Foo) => Bar; type Baz = Foo; -declare const convert2: (value: Foo) => Foo; +declare const convert2: (value: Foo) => Baz; declare function f31(): void; declare function f32(): void; declare function f33(): void; diff --git a/tests/baselines/reference/conditionalTypes1.types b/tests/baselines/reference/conditionalTypes1.types index 5f9770492ded1..01c6b452bdfbe 100644 --- a/tests/baselines/reference/conditionalTypes1.types +++ b/tests/baselines/reference/conditionalTypes1.types @@ -789,8 +789,8 @@ type Baz = Foo; >Baz : Baz const convert2 = (value: Foo): Baz => value; ->convert2 : (value: Foo) => Foo ->(value: Foo): Baz => value : (value: Foo) => Foo +>convert2 : (value: Foo) => Baz +>(value: Foo): Baz => value : (value: Foo) => Baz >value : Foo >value : Foo diff --git a/tests/baselines/reference/conditionalTypesSimplifyWhenTrivial.types b/tests/baselines/reference/conditionalTypesSimplifyWhenTrivial.types index 46173b625832e..2f27a38d71b26 100644 --- a/tests/baselines/reference/conditionalTypesSimplifyWhenTrivial.types +++ b/tests/baselines/reference/conditionalTypesSimplifyWhenTrivial.types @@ -59,8 +59,8 @@ type ExcludeWithDefault = T extends U ? D : T; >ExcludeWithDefault : ExcludeWithDefault const fn5 = ( ->fn5 : (params: Pick>) => Params ->( params: Pick>,): Params => params : (params: Pick>) => Params +>fn5 : (params: Pick>) => Params +>( params: Pick>,): Params => params : (params: Pick>) => Params params: Pick>, >params : Pick> @@ -83,8 +83,8 @@ function fn6(x: ExcludeWithDefault) { } const fn7 = ( ->fn7 : (params: Pick>) => Params ->( params: Pick>,): Params => params : (params: Pick>) => Params +>fn7 : (params: Pick>) => Params +>( params: Pick>,): Params => params : (params: Pick>) => Params params: Pick>, >params : Pick> diff --git a/tests/baselines/reference/conflictingDeclarationsImportFromNamespace2.types b/tests/baselines/reference/conflictingDeclarationsImportFromNamespace2.types index 21b55ae75a2ef..64be2e260dda2 100644 --- a/tests/baselines/reference/conflictingDeclarationsImportFromNamespace2.types +++ b/tests/baselines/reference/conflictingDeclarationsImportFromNamespace2.types @@ -9,7 +9,7 @@ declare module "./index" { interface LoDashStatic { pick: ( ->pick : (object: T, ...props: U[]) => Pick +>pick : (object: T, ...props: Array) => Pick object: T, >object : T diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types index 0bed3a62c2184..2ff0dba4385c1 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types @@ -233,7 +233,7 @@ interface I extends A { >y : T a14: new (x: { a: T; b: U }) => T; // ok ->a14 : new (x: { a: T; b: U; }) => T +>a14 : new (x: { a: T; b: U;}) => T >x : { a: T; b: U; } >a : T >b : U diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.types index 05dd7752d4573..e342e13f9b931 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.types @@ -161,7 +161,7 @@ module Errors { interface I6 extends A { a15: new (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type ->a15 : new (x: { a: T; b: T; }) => T +>a15 : new (x: { a: T; b: T;}) => T >x : { a: T; b: T; } >a : T >b : T @@ -169,7 +169,7 @@ module Errors { interface I7 extends A { a15: new (x: { a: T; b: T }) => number; // error, T defaults to Base, which is not compatible with number or string ->a15 : new (x: { a: T; b: T; }) => number +>a15 : new (x: { a: T; b: T;}) => number >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.types index 8708a9c578b3c..a7349d835cd0c 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.types @@ -52,7 +52,7 @@ interface A { // T >arg : T a11: new (x: { foo: T }, y: { foo: T; bar: T }) => Base; ->a11 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base +>a11 : new (x: { foo: T;}, y: { foo: T; bar: T;}) => Base >x : { foo: T; } >foo : T >y : { foo: T; bar: T; } @@ -60,13 +60,13 @@ interface A { // T >bar : T a15: new (x: { a: T; b: T }) => T[]; ->a15 : new (x: { a: T; b: T; }) => T[] +>a15 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T a16: new (x: { a: T; b: T }) => T[]; ->a16 : new (x: { a: T; b: T; }) => T[] +>a16 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T @@ -160,7 +160,7 @@ interface I extends A { >arg : T a11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; // ok ->a11 : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base +>a11 : new (x: { foo: T;}, y: { foo: U; bar: U;}) => Base >x : { foo: T; } >foo : T >y : { foo: U; bar: U; } @@ -168,13 +168,13 @@ interface I extends A { >bar : U a15: new (x: { a: U; b: V; }) => U[]; // ok, T = U, T = V ->a15 : new (x: { a: U; b: V; }) => U[] +>a15 : new (x: { a: U; b: V;}) => U[] >x : { a: U; b: V; } >a : U >b : V a16: new (x: { a: T; b: T }) => T[]; // ok, more general parameter type ->a16 : new (x: { a: T; b: T; }) => T[] +>a16 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types index 586f63a410f87..8a9c1737fc4c0 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types @@ -183,7 +183,7 @@ interface I extends B { >y : T a14: new (x: { a: T; b: U }) => T; // ok ->a14 : new (x: { a: T; b: U; }) => T +>a14 : new (x: { a: T; b: U;}) => T >x : { a: T; b: U; } >a : T >b : U diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.types index 065dd2478a504..7477c180797a4 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.types @@ -54,7 +54,7 @@ interface A { // T >arg : T a11: new (x: { foo: T }, y: { foo: T; bar: T }) => Base; ->a11 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base +>a11 : new (x: { foo: T;}, y: { foo: T; bar: T;}) => Base >x : { foo: T; } >foo : T >y : { foo: T; bar: T; } @@ -62,13 +62,13 @@ interface A { // T >bar : T a15: new (x: { a: T; b: T }) => T[]; ->a15 : new (x: { a: T; b: T; }) => T[] +>a15 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T a16: new (x: { a: T; b: T }) => T[]; ->a16 : new (x: { a: T; b: T; }) => T[] +>a16 : new (x: { a: T; b: T;}) => T[] >x : { a: T; b: T; } >a : T >b : T @@ -109,7 +109,7 @@ interface I5 extends A { interface I7 extends A { a11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; ->a11 : new (x: { foo: T;}, y: { foo: U; bar: U; }) => Base +>a11 : new (x: { foo: T;}, y: { foo: U; bar: U;}) => Base >x : { foo: T; } >foo : T >y : { foo: U; bar: U; } diff --git a/tests/baselines/reference/correlatedUnions.js b/tests/baselines/reference/correlatedUnions.js index 5335811054601..05e77d8b4d3e1 100644 --- a/tests/baselines/reference/correlatedUnions.js +++ b/tests/baselines/reference/correlatedUnions.js @@ -602,7 +602,7 @@ type SameKeys = { }; }; type MappedFromOriginal = SameKeys; -declare const getStringAndNumberFromOriginalAndMapped: (original: Original, mappedFromOriginal: MappedFromOriginal, key: K, nestedKey: N) => [Original[K][N], SameKeys[K][N]]; +declare const getStringAndNumberFromOriginalAndMapped: (original: Original, mappedFromOriginal: MappedFromOriginal, key: K, nestedKey: N) => [Original[K][N], MappedFromOriginal[K][N]]; interface Config { string: string; number: number; diff --git a/tests/baselines/reference/correlatedUnions.types b/tests/baselines/reference/correlatedUnions.types index 8d328d6c66f79..70cb53fee6925 100644 --- a/tests/baselines/reference/correlatedUnions.types +++ b/tests/baselines/reference/correlatedUnions.types @@ -797,8 +797,8 @@ type MappedFromOriginal = SameKeys; >MappedFromOriginal : SameKeys const getStringAndNumberFromOriginalAndMapped = < ->getStringAndNumberFromOriginalAndMapped : (original: Original, mappedFromOriginal: MappedFromOriginal, key: K, nestedKey: N) => [Original[K][N], SameKeys[K][N]] ->< K extends KeyOfOriginal, N extends NestedKeyOfOriginalFor>( original: Original, mappedFromOriginal: MappedFromOriginal, key: K, nestedKey: N): [Original[K][N], MappedFromOriginal[K][N]] => { return [original[key][nestedKey], mappedFromOriginal[key][nestedKey]];} : (original: Original, mappedFromOriginal: MappedFromOriginal, key: K, nestedKey: N) => [Original[K][N], SameKeys[K][N]] +>getStringAndNumberFromOriginalAndMapped : (original: Original, mappedFromOriginal: MappedFromOriginal, key: K, nestedKey: N) => [Original[K][N], MappedFromOriginal[K][N]] +>< K extends KeyOfOriginal, N extends NestedKeyOfOriginalFor>( original: Original, mappedFromOriginal: MappedFromOriginal, key: K, nestedKey: N): [Original[K][N], MappedFromOriginal[K][N]] => { return [original[key][nestedKey], mappedFromOriginal[key][nestedKey]];} : (original: Original, mappedFromOriginal: MappedFromOriginal, key: K, nestedKey: N) => [Original[K][N], MappedFromOriginal[K][N]] K extends KeyOfOriginal, N extends NestedKeyOfOriginalFor diff --git a/tests/baselines/reference/declarationEmitDistributiveConditionalWithInfer.types b/tests/baselines/reference/declarationEmitDistributiveConditionalWithInfer.types index b3f1ab2f1136b..ce30394a12254 100644 --- a/tests/baselines/reference/declarationEmitDistributiveConditionalWithInfer.types +++ b/tests/baselines/reference/declarationEmitDistributiveConditionalWithInfer.types @@ -7,7 +7,7 @@ export const fun = ( >( subFun: () => FlatArray[]) => { } : (subFun: () => (Collection[Field] extends readonly (infer InnerArr)[] ? InnerArr : Collection[Field])[]) => void subFun: () ->subFun : () => (Collection[Field] extends readonly (infer InnerArr)[] ? InnerArr : Collection[Field])[] +>subFun : () => FlatArray[] => FlatArray[]) => { }; diff --git a/tests/baselines/reference/declarationEmitPrivatePromiseLikeInterface.js b/tests/baselines/reference/declarationEmitPrivatePromiseLikeInterface.js index fca79b431ed2a..dec8e1bbe65e9 100644 --- a/tests/baselines/reference/declarationEmitPrivatePromiseLikeInterface.js +++ b/tests/baselines/reference/declarationEmitPrivatePromiseLikeInterface.js @@ -72,6 +72,6 @@ export interface HttpResponse ex error: E; } export declare class HttpClient { - request: () => TPromise, any>; + request: () => TPromise>; } export {}; diff --git a/tests/baselines/reference/declarationEmitReusesLambdaParameterNodes.js b/tests/baselines/reference/declarationEmitReusesLambdaParameterNodes.js new file mode 100644 index 0000000000000..bbf4da08184d4 --- /dev/null +++ b/tests/baselines/reference/declarationEmitReusesLambdaParameterNodes.js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/declarationEmitReusesLambdaParameterNodes.ts] //// + +//// [index.d.ts] +export type Whatever = {x: string, y: number}; +export type Props = Omit & Partial & T; + +//// [index.ts] +import { Props } from "react-select"; + +export const CustomSelect1 = (x: Props