diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9dc9efdf514..810b47c3d4a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12693,10 +12693,11 @@ namespace ts { else if (source.flags & TypeFlags.Conditional) { if (target.flags & TypeFlags.Conditional) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if - // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, - // and Y1 is related to Y2. - if (isTypeIdenticalTo((source).extendsType, (target).extendsType) && - (isRelatedTo((source).checkType, (target).checkType) || isRelatedTo((target).checkType, (source).checkType))) { + // they have the same distributivity, T1 and T2 are identical types, U1 and U2 are identical + // types, X1 is related to X2, and Y1 is related to Y2. + if ((source).root.isDistributive === (target).root.isDistributive && + isTypeIdenticalTo((source).extendsType, (target).extendsType) && + isTypeIdenticalTo((source).checkType, (target).checkType)) { if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } @@ -21539,13 +21540,8 @@ namespace ts { } if (signature.hasRestParameter) { const restType = getTypeOfSymbol(signature.parameters[paramCount]); - if (isTupleType(restType)) { - if (pos - paramCount < getLengthOfTupleType(restType)) { - return restType.typeArguments![pos - paramCount]; - } - return getRestTypeOfTupleType(restType); - } - return getIndexTypeOfType(restType, IndexKind.Number); + const indexType = getLiteralType(pos - paramCount); + return getIndexedAccessType(restType, indexType); } return undefined; } @@ -21553,18 +21549,22 @@ namespace ts { function getRestTypeAtPosition(source: Signature, pos: number): Type { const paramCount = getParameterCount(source); const restType = getEffectiveRestType(source); - if (restType && pos === paramCount - 1) { + const nonRestCount = paramCount - (restType ? 1 : 0); + if (restType && pos === nonRestCount) { return restType; } - const start = restType ? Math.min(pos, paramCount - 1) : pos; const types = []; const names = []; - for (let i = start; i < paramCount; i++) { + for (let i = pos; i < nonRestCount; i++) { types.push(getTypeAtPosition(source, i)); names.push(getParameterNameAtPosition(source, i)); } + if (restType) { + types.push(getIndexedAccessType(restType, numberType)); + names.push(getParameterNameAtPosition(source, nonRestCount)); + } const minArgumentCount = getMinArgumentCount(source); - const minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + const minLength = minArgumentCount < pos ? 0 : minArgumentCount - pos; return createTupleType(types, minLength, !!restType, /*readonly*/ false, names); } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 6dccc08c4b5..e9d97f6e03c 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -7,7 +7,6 @@ namespace ts.server { export const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; export const ProjectLoadingStartEvent = "projectLoadingStart"; export const ProjectLoadingFinishEvent = "projectLoadingFinish"; - export const SurveyReady = "surveyReady"; export const LargeFileReferencedEvent = "largeFileReferenced"; export const ConfigFileDiagEvent = "configFileDiag"; export const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; @@ -30,11 +29,6 @@ namespace ts.server { data: { project: Project; }; } - export interface SurveyReady { - eventName: typeof SurveyReady; - data: { surveyId: string; }; - } - export interface LargeFileReferencedEvent { eventName: typeof LargeFileReferencedEvent; data: { file: string; fileSize: number; maxFileSize: number; }; @@ -146,7 +140,6 @@ namespace ts.server { } export type ProjectServiceEvent = LargeFileReferencedEvent | - SurveyReady | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | @@ -518,9 +511,6 @@ namespace ts.server { /** Tracks projects that we have already sent telemetry for. */ private readonly seenProjects = createMap(); - /** Tracks projects that we have already sent survey events for. */ - private readonly seenSurveyProjects = createMap(); - /*@internal*/ readonly watchFactory: WatchFactory; @@ -722,14 +712,6 @@ namespace ts.server { this.eventHandler(event); } - /* @internal */ - sendSurveyReadyEvent(surveyId: string) { - if (!this.eventHandler) { - return; - } - this.eventHandler({ eventName: SurveyReady, data: { surveyId } }); - } - /* @internal */ sendLargeFileReferencedEvent(file: string, fileSize: number) { if (!this.eventHandler) { @@ -1611,20 +1593,6 @@ namespace ts.server { return project; } - /*@internal*/ - sendSurveyReady(project: ExternalProject | ConfiguredProject): void { - if (this.seenSurveyProjects.has(project.projectName)) { - return; - } - - if (project.getCompilerOptions().checkJs !== undefined) { - const name = "checkJs"; - this.logger.info(`Survey ${name} is ready`); - this.sendSurveyReadyEvent(name); - this.seenSurveyProjects.set(project.projectName, true); - } - } - /*@internal*/ sendProjectTelemetry(project: ExternalProject | ConfiguredProject): void { if (this.seenProjects.has(project.projectName)) { diff --git a/src/server/project.ts b/src/server/project.ts index b296668e6ae..280cedb424d 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1431,7 +1431,6 @@ namespace ts.server { } this.projectService.sendProjectLoadingFinishEvent(this); this.projectService.sendProjectTelemetry(this); - this.projectService.sendSurveyReady(this); return result; } @@ -1627,7 +1626,6 @@ namespace ts.server { updateGraph() { const result = super.updateGraph(); this.projectService.sendProjectTelemetry(this); - this.projectService.sendSurveyReady(this); return result; } diff --git a/src/server/session.ts b/src/server/session.ts index e5b128c984e..b47dfe6b716 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -610,10 +610,6 @@ namespace ts.server { diagnostics: bakedDiags }, ConfigFileDiagEvent); break; - case SurveyReady: - const { surveyId } = event.data; - this.event({ surveyId }, SurveyReady); - break; case ProjectLanguageServiceStateEvent: { const eventName: protocol.ProjectLanguageServiceStateEventName = ProjectLanguageServiceStateEvent; this.event({ diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 7e75c0105a2..137e4d8af58 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -109,7 +109,6 @@ "unittests/tsserver/events/projectLanguageServiceState.ts", "unittests/tsserver/events/projectLoading.ts", "unittests/tsserver/events/projectUpdatedInBackground.ts", - "unittests/tsserver/events/surveyReady.ts", "unittests/tsserver/externalProjects.ts", "unittests/tsserver/forceConsistentCasingInFileNames.ts", "unittests/tsserver/formatSettings.ts", diff --git a/src/testRunner/unittests/tsserver/events/surveyReady.ts b/src/testRunner/unittests/tsserver/events/surveyReady.ts deleted file mode 100644 index b04746800d0..00000000000 --- a/src/testRunner/unittests/tsserver/events/surveyReady.ts +++ /dev/null @@ -1,111 +0,0 @@ -namespace ts.projectSystem { - describe("unittests:: tsserver:: events:: SurveyReady", () => { - function createSessionWithEventHandler(host: TestServerHost) { - const { session, events: surveyEvents } = createSessionWithEventTracking(host, server.SurveyReady); - - return { session, verifySurveyReadyEvent }; - - function verifySurveyReadyEvent(numberOfEvents: number) { - assert.equal(surveyEvents.length, numberOfEvents); - const expectedEvents = numberOfEvents === 0 ? [] : [{ - eventName: server.SurveyReady, - data: { surveyId: "checkJs" } - }]; - assert.deepEqual(surveyEvents, expectedEvents); - } - } - - it("doesn't log an event when checkJs isn't set", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: {} }), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - const service = session.getProjectService(); - openFilesForSession([file], session); - checkNumberOfProjects(service, { configuredProjects: 1 }); - const project = service.configuredProjects.get(tsconfig.path)!; - checkProjectActualFiles(project, [file.path, tsconfig.path]); - - verifySurveyReadyEvent(0); - }); - - it("logs an event when checkJs is set", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: { checkJs: true } }), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - }); - - it("logs an event when checkJs is set, only the first time", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const rando: File = { - path: `/rando/calrissian.ts`, - content: "export function f() { }" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: { checkJs: true } }), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - - closeFilesForSession([file], session); - openFilesForSession([rando], session); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - }); - - it("logs an event when checkJs is set after closing and reopening", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const rando: File = { - path: `/rando/calrissian.ts`, - content: "export function f() { }" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({}), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - openFilesForSession([file], session); - - verifySurveyReadyEvent(0); - - closeFilesForSession([file], session); - openFilesForSession([rando], session); - host.writeFile(tsconfig.path, JSON.stringify({ compilerOptions: { checkJs: true } })); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - }); - }); -} diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 025880dc09e..36c246c999f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -8357,7 +8357,6 @@ declare namespace ts.server { const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; const ProjectLoadingStartEvent = "projectLoadingStart"; const ProjectLoadingFinishEvent = "projectLoadingFinish"; - const SurveyReady = "surveyReady"; const LargeFileReferencedEvent = "largeFileReferenced"; const ConfigFileDiagEvent = "configFileDiag"; const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; @@ -8382,12 +8381,6 @@ declare namespace ts.server { project: Project; }; } - interface SurveyReady { - eventName: typeof SurveyReady; - data: { - surveyId: string; - }; - } interface LargeFileReferencedEvent { eventName: typeof LargeFileReferencedEvent; data: { @@ -8472,7 +8465,7 @@ declare namespace ts.server { interface OpenFileInfo { readonly checkJs: boolean; } - type ProjectServiceEvent = LargeFileReferencedEvent | SurveyReady | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; + type ProjectServiceEvent = LargeFileReferencedEvent | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void; interface SafeList { [name: string]: { @@ -8589,8 +8582,6 @@ declare namespace ts.server { readonly syntaxOnly?: boolean; /** Tracks projects that we have already sent telemetry for. */ private readonly seenProjects; - /** Tracks projects that we have already sent survey events for. */ - private readonly seenSurveyProjects; constructor(opts: ProjectServiceOptions); toPath(fileName: string): Path; private loadTypesMap; diff --git a/tests/baselines/reference/conditionalTypes2.errors.txt b/tests/baselines/reference/conditionalTypes2.errors.txt index a1a23b6da18..343a0a8412c 100644 --- a/tests/baselines/reference/conditionalTypes2.errors.txt +++ b/tests/baselines/reference/conditionalTypes2.errors.txt @@ -1,29 +1,38 @@ -tests/cases/conformance/types/conditional/conditionalTypes2.ts(15,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(19,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(24,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(16,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. + Types of property 'foo' are incompatible. + Type 'B extends string ? B : number' is not assignable to type 'A extends string ? A : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(17,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. + Types of property 'foo' are incompatible. + Type 'A extends string ? A : number' is not assignable to type 'B extends string ? B : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(21,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. + Types of property 'foo' are incompatible. + Type 'B extends string ? keyof B : number' is not assignable to type 'A extends string ? keyof A : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(22,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. + Types of property 'foo' are incompatible. + Type 'A extends string ? keyof A : number' is not assignable to type 'B extends string ? keyof B : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(26,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. - Type 'keyof B' is not assignable to type 'keyof A'. - Type 'string | number | symbol' is not assignable to type 'keyof A'. - Type 'string' is not assignable to type 'keyof A'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(25,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(27,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(73,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(74,12): error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(76,12): error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(77,12): error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. Type 'T extends Bar ? T : never' is not assignable to type '{ foo: string; bat: string; }'. Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(165,5): error TS2322: Type 'MyElement' is not assignable to type 'MyElement'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(170,5): error TS2322: Type 'MyAcceptor' is not assignable to type 'MyAcceptor'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(177,5): error TS2322: Type 'Dist' is not assignable to type 'Aux<{ a: T; }>'. -==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (7 errors) ==== +==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (12 errors) ==== + // #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; } @@ -37,19 +46,29 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 } function f1(a: Covariant, b: Covariant) { - a = b; + a = b; // Error + ~ +!!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'B extends string ? B : number' is not assignable to type 'A extends string ? A : number'. b = a; // Error ~ !!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'A extends string ? A : number' is not assignable to type 'B extends string ? B : number'. } function f2(a: Contravariant, b: Contravariant) { a = b; // Error ~ !!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. - b = a; +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'B extends string ? keyof B : number' is not assignable to type 'A extends string ? keyof A : number'. + b = a; // Error + ~ +!!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'A extends string ? keyof A : number' is not assignable to type 'B extends string ? keyof B : number'. } function f3(a: Invariant, b: Invariant) { @@ -58,15 +77,11 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. -!!! error TS2322: Type 'keyof B' is not assignable to type 'keyof A'. -!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'keyof A'. -!!! error TS2322: Type 'string' is not assignable to type 'keyof A'. b = a; // Error ~ !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. } // Extract is a T that is known to be a Function @@ -120,13 +135,13 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. !!! error TS2345: Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. fooBat(y); // Error ~ !!! error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. fooBat(z); // Error ~ !!! error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. @@ -134,38 +149,6 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2345: Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. } - // Repros from #22860 - - class Opt { - toVector(): Vector { - return undefined; - } - } - - interface Seq { - tail(): Opt>; - } - - class Vector implements Seq { - tail(): Opt> { - return undefined; - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { - return undefined; - } - } - - interface A1 { - bat: B1>; - } - - interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true - } - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -246,4 +229,29 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; + + // Repros from #27118 + + type MyElement = [A] extends [[infer E]] ? E : never; + function oops(arg: MyElement): MyElement { + return arg; // Unsound, should be error + ~~~~~~~~~~~ +!!! error TS2322: Type 'MyElement' is not assignable to type 'MyElement'. + } + + type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; + function oops2(arg: MyAcceptor): MyAcceptor { + return arg; // Unsound, should be error + ~~~~~~~~~~~ +!!! error TS2322: Type 'MyAcceptor' is not assignable to type 'MyAcceptor'. + } + + type Dist = T extends number ? number : string; + type Aux = A["a"] extends number ? number : string; + type Nondist = Aux<{a: T}>; + function oops3(arg: Dist): Nondist { + return arg; // Unsound, should be error + ~~~~~~~~~~~ +!!! error TS2322: Type 'Dist' is not assignable to type 'Aux<{ a: T; }>'. + } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypes2.js b/tests/baselines/reference/conditionalTypes2.js index 4f4f35e821a..c59c996711d 100644 --- a/tests/baselines/reference/conditionalTypes2.js +++ b/tests/baselines/reference/conditionalTypes2.js @@ -1,4 +1,6 @@ //// [conditionalTypes2.ts] +// #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; } @@ -12,13 +14,13 @@ interface Invariant { } function f1(a: Covariant, b: Covariant) { - a = b; + a = b; // Error b = a; // Error } function f2(a: Contravariant, b: Contravariant) { a = b; // Error - b = a; + b = a; // Error } function f3(a: Invariant, b: Invariant) { @@ -76,38 +78,6 @@ function f21(x: Extract, Bar>, y: Extract, z: E fooBat(z); // Error } -// Repros from #22860 - -class Opt { - toVector(): Vector { - return undefined; - } -} - -interface Seq { - tail(): Opt>; -} - -class Vector implements Seq { - tail(): Opt> { - return undefined; - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { - return undefined; - } -} - -interface A1 { - bat: B1>; -} - -interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true -} - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -188,17 +158,37 @@ type ProductComplementComplement = { }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; + +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +function oops(arg: MyElement): MyElement { + return arg; // Unsound, should be error +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +function oops2(arg: MyAcceptor): MyAcceptor { + return arg; // Unsound, should be error +} + +type Dist = T extends number ? number : string; +type Aux = A["a"] extends number ? number : string; +type Nondist = Aux<{a: T}>; +function oops3(arg: Dist): Nondist { + return arg; // Unsound, should be error +} //// [conditionalTypes2.js] "use strict"; +// #27118: Conditional types are now invariant in the check type. function f1(a, b) { - a = b; + a = b; // Error b = a; // Error } function f2(a, b) { a = b; // Error - b = a; + b = a; // Error } function f3(a, b) { a = b; // Error @@ -239,32 +229,21 @@ function f21(x, y, z) { fooBat(y); // Error fooBat(z); // Error } -// Repros from #22860 -var Opt = /** @class */ (function () { - function Opt() { - } - Opt.prototype.toVector = function () { - return undefined; - }; - return Opt; -}()); -var Vector = /** @class */ (function () { - function Vector() { - } - Vector.prototype.tail = function () { - return undefined; - }; - Vector.prototype.partition2 = function (predicate) { - return undefined; - }; - return Vector; -}()); function foo(value) { if (isFunction(value)) { toString1(value); toString2(value); } } +function oops(arg) { + return arg; // Unsound, should be error +} +function oops2(arg) { + return arg; // Unsound, should be error +} +function oops3(arg) { + return arg; // Unsound, should be error +} //// [conditionalTypes2.d.ts] @@ -302,24 +281,6 @@ declare function fooBat(x: { declare type Extract2 = T extends U ? T extends V ? T : never : never; declare function f20(x: Extract, Bar>, y: Extract, z: Extract2): void; declare function f21(x: Extract, Bar>, y: Extract, z: Extract2): void; -declare class Opt { - toVector(): Vector; -} -interface Seq { - tail(): Opt>; -} -declare class Vector implements Seq { - tail(): Opt>; - partition2(predicate: (v: T) => v is U): [Vector, Vector>]; - partition2(predicate: (x: T) => boolean): [Vector, Vector]; -} -interface A1 { - bat: B1>; -} -interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true; -} declare function toString1(value: object | Function): string; declare function toString2(value: Function): string; declare function foo(value: T): void; @@ -392,3 +353,15 @@ declare type ProductComplementComplement = { }; declare type PCCA = ProductComplementComplement['a']; declare type PCCB = ProductComplementComplement['b']; +declare type MyElement = [A] extends [[infer E]] ? E : never; +declare function oops(arg: MyElement): MyElement; +declare type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +declare function oops2(arg: MyAcceptor): MyAcceptor; +declare type Dist = T extends number ? number : string; +declare type Aux = A["a"] extends number ? number : string; +declare type Nondist = Aux<{ + a: T; +}>; +declare function oops3(arg: Dist): Nondist; diff --git a/tests/baselines/reference/conditionalTypes2.symbols b/tests/baselines/reference/conditionalTypes2.symbols index b164d26e450..7bbf837eece 100644 --- a/tests/baselines/reference/conditionalTypes2.symbols +++ b/tests/baselines/reference/conditionalTypes2.symbols @@ -1,687 +1,655 @@ === tests/cases/conformance/types/conditional/conditionalTypes2.ts === +// #27118: Conditional types are now invariant in the check type. + interface Covariant { >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) foo: T extends string ? T : number; ->foo : Symbol(Covariant.foo, Decl(conditionalTypes2.ts, 0, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) +>foo : Symbol(Covariant.foo, Decl(conditionalTypes2.ts, 2, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) } interface Contravariant { ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) foo: T extends string ? keyof T : number; ->foo : Symbol(Contravariant.foo, Decl(conditionalTypes2.ts, 4, 28)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) +>foo : Symbol(Contravariant.foo, Decl(conditionalTypes2.ts, 6, 28)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) } interface Invariant { ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) foo: T extends string ? keyof T : T; ->foo : Symbol(Invariant.foo, Decl(conditionalTypes2.ts, 8, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) +>foo : Symbol(Invariant.foo, Decl(conditionalTypes2.ts, 10, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) } function f1(a: Covariant, b: Covariant) { ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 10, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 12, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 12, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 14, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 12, 14)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 14, 14)) - a = b; ->a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) + a = b; // Error +>a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) b = a; // Error ->b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) } function f2(a: Contravariant, b: Contravariant) { ->f2 : Symbol(f2, Decl(conditionalTypes2.ts, 15, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 17, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 17, 14)) +>f2 : Symbol(f2, Decl(conditionalTypes2.ts, 17, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 19, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 19, 14)) a = b; // Error ->a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) - b = a; ->b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) + b = a; // Error +>b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) } function f3(a: Invariant, b: Invariant) { ->f3 : Symbol(f3, Decl(conditionalTypes2.ts, 20, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 22, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 22, 14)) +>f3 : Symbol(f3, Decl(conditionalTypes2.ts, 22, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 24, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 24, 14)) a = b; // Error ->a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) b = a; // Error ->b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) } // Extract is a T that is known to be a Function function isFunction(value: T): value is Extract { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return typeof value === "function"; ->value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) } function getFunction(item: T) { ->getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 30, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 32, 21)) ->item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 32, 21)) +>getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 32, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 34, 21)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 34, 21)) if (isFunction(item)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) return item; ->item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) } throw new Error(); >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } function f10(x: T) { ->f10 : Symbol(f10, Decl(conditionalTypes2.ts, 37, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) +>f10 : Symbol(f10, Decl(conditionalTypes2.ts, 39, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) if (isFunction(x)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) const f: Function = x; ->f : Symbol(f, Decl(conditionalTypes2.ts, 41, 13)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 43, 13)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) const t: T = x; ->t : Symbol(t, Decl(conditionalTypes2.ts, 42, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>t : Symbol(t, Decl(conditionalTypes2.ts, 44, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) } } function f11(x: string | (() => string) | undefined) { ->f11 : Symbol(f11, Decl(conditionalTypes2.ts, 44, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) +>f11 : Symbol(f11, Decl(conditionalTypes2.ts, 46, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) if (isFunction(x)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) x(); ->x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) } } function f12(x: string | (() => string) | undefined) { ->f12 : Symbol(f12, Decl(conditionalTypes2.ts, 50, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 52, 13)) +>f12 : Symbol(f12, Decl(conditionalTypes2.ts, 52, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 54, 13)) const f = getFunction(x); // () => string ->f : Symbol(f, Decl(conditionalTypes2.ts, 53, 9)) ->getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 30, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 52, 13)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 55, 9)) +>getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 32, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 54, 13)) f(); ->f : Symbol(f, Decl(conditionalTypes2.ts, 53, 9)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 55, 9)) } type Foo = { foo: string }; ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 57, 12)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 59, 12)) type Bar = { bar: string }; ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->bar : Symbol(bar, Decl(conditionalTypes2.ts, 58, 12)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>bar : Symbol(bar, Decl(conditionalTypes2.ts, 60, 12)) declare function fooBar(x: { foo: string, bar: string }): void; ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 60, 24)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 60, 28)) ->bar : Symbol(bar, Decl(conditionalTypes2.ts, 60, 41)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 62, 24)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 62, 28)) +>bar : Symbol(bar, Decl(conditionalTypes2.ts, 62, 41)) declare function fooBat(x: { foo: string, bat: string }): void; ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 61, 24)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 61, 28)) ->bat : Symbol(bat, Decl(conditionalTypes2.ts, 61, 41)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 63, 24)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 63, 28)) +>bat : Symbol(bat, Decl(conditionalTypes2.ts, 63, 41)) type Extract2 = T extends U ? T extends V ? T : never : never; ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 63, 16)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 63, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 63, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 63, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 65, 16)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 65, 19)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 65, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 65, 19)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) function f20(x: Extract, Bar>, y: Extract, z: Extract2) { ->f20 : Symbol(f20, Decl(conditionalTypes2.ts, 63, 71)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 65, 16)) +>f20 : Symbol(f20, Decl(conditionalTypes2.ts, 65, 71)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 67, 16)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 65, 49)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 67, 49)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 65, 75)) ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 67, 75)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) fooBar(x); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 65, 16)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 67, 16)) fooBar(y); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 65, 49)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 67, 49)) fooBar(z); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 65, 75)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 67, 75)) } function f21(x: Extract, Bar>, y: Extract, z: Extract2) { ->f21 : Symbol(f21, Decl(conditionalTypes2.ts, 69, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 71, 16)) +>f21 : Symbol(f21, Decl(conditionalTypes2.ts, 71, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 73, 16)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 71, 49)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 73, 49)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 71, 75)) ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 73, 75)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) fooBat(x); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 71, 16)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 73, 16)) fooBat(y); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 71, 49)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 73, 49)) fooBat(z); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 71, 75)) -} - -// Repros from #22860 - -class Opt { ->Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 79, 10)) - - toVector(): Vector { ->toVector : Symbol(Opt.toVector, Decl(conditionalTypes2.ts, 79, 14)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 79, 10)) - - return undefined; ->undefined : Symbol(undefined) - } -} - -interface Seq { ->Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 85, 14)) - - tail(): Opt>; ->tail : Symbol(Seq.tail, Decl(conditionalTypes2.ts, 85, 18)) ->Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) ->Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 85, 14)) -} - -class Vector implements Seq { ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) - - tail(): Opt> { ->tail : Symbol(Vector.tail, Decl(conditionalTypes2.ts, 89, 35)) ->Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) - - return undefined; ->undefined : Symbol(undefined) - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; ->partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 93, 28)) ->v : Symbol(v, Decl(conditionalTypes2.ts, 93, 39)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->v : Symbol(v, Decl(conditionalTypes2.ts, 93, 39)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) - - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; ->partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) ->predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 94, 15)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 94, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) - - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { ->partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 95, 15)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 95, 28)) ->v : Symbol(v, Decl(conditionalTypes2.ts, 95, 39)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 95, 15)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) - - return undefined; ->undefined : Symbol(undefined) - } -} - -interface A1 { ->A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 100, 13)) - - bat: B1>; ->bat : Symbol(A1.bat, Decl(conditionalTypes2.ts, 100, 17)) ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 100, 13)) -} - -interface B1 extends A1 { ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) ->A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) - - bat: B1>; ->bat : Symbol(B1.bat, Decl(conditionalTypes2.ts, 104, 31)) ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) - - boom: T extends any ? true : true ->boom : Symbol(B1.boom, Decl(conditionalTypes2.ts, 105, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 73, 75)) } // Repro from #22899 declare function toString1(value: object | Function): string ; ->toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 107, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 111, 27)) +>toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 77, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 81, 27)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function toString2(value: Function): string ; ->toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 111, 62)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 112, 27)) +>toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 81, 62)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 82, 27)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) function foo(value: T) { ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 112, 53)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 13)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 13)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 82, 53)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 84, 13)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 84, 13)) if (isFunction(value)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) toString1(value); ->toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 107, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 77, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) toString2(value); ->toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 111, 62)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 81, 62)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) } } // Repro from #23052 type A = ->A : Symbol(A, Decl(conditionalTypes2.ts, 119, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 123, 12)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 89, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 93, 12)) T extends object ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) ? { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: A; } ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 125, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 119, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 125, 9)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 123, 12)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 95, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 89, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 95, 9)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 93, 12)) : T extends V ? T : never; ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) type B = ->B : Symbol(B, Decl(conditionalTypes2.ts, 126, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 96, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) T extends object ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) ? { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: B; } ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 130, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 126, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 130, 9)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 100, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 96, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 100, 9)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) : T extends V ? T : never; ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) type C = ->C : Symbol(C, Decl(conditionalTypes2.ts, 131, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 133, 12)) +>C : Symbol(C, Decl(conditionalTypes2.ts, 101, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 103, 12)) { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: C; }; ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 134, 5)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->C : Symbol(C, Decl(conditionalTypes2.ts, 131, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 134, 5)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 133, 12)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 104, 5)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>C : Symbol(C, Decl(conditionalTypes2.ts, 101, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 104, 5)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 103, 12)) // Repro from #23100 type A2 = ->A2 : Symbol(A2, Decl(conditionalTypes2.ts, 134, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 138, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 138, 13)) +>A2 : Symbol(A2, Decl(conditionalTypes2.ts, 104, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 108, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 108, 13)) T extends object ? T extends any[] ? T : { [Q in keyof T]: A2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 139, 48)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->A2 : Symbol(A2, Decl(conditionalTypes2.ts, 134, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 139, 48)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 138, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 138, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 109, 48)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>A2 : Symbol(A2, Decl(conditionalTypes2.ts, 104, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 109, 48)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 108, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 108, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) type B2 = ->B2 : Symbol(B2, Decl(conditionalTypes2.ts, 139, 85)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 141, 10)) +>B2 : Symbol(B2, Decl(conditionalTypes2.ts, 109, 85)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 111, 10)) T extends object ? T extends any[] ? T : { [Q in keyof T]: B2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 142, 48)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->B2 : Symbol(B2, Decl(conditionalTypes2.ts, 139, 85)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 142, 48)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 141, 10)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 112, 48)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>B2 : Symbol(B2, Decl(conditionalTypes2.ts, 109, 85)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 112, 48)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 111, 10)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) type C2 = ->C2 : Symbol(C2, Decl(conditionalTypes2.ts, 142, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 144, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 144, 13)) +>C2 : Symbol(C2, Decl(conditionalTypes2.ts, 112, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 114, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 114, 13)) T extends object ? { [Q in keyof T]: C2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 145, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->C2 : Symbol(C2, Decl(conditionalTypes2.ts, 142, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 145, 26)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 144, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 144, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 115, 26)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>C2 : Symbol(C2, Decl(conditionalTypes2.ts, 112, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 115, 26)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 114, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 114, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) // Repro from #28654 type MaybeTrue = true extends T["b"] ? "yes" : "no"; ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 149, 15)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 149, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 149, 15)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 119, 15)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 119, 26)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 119, 15)) type T0 = MaybeTrue<{ b: never }> // "no" ->T0 : Symbol(T0, Decl(conditionalTypes2.ts, 149, 78)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 151, 21)) +>T0 : Symbol(T0, Decl(conditionalTypes2.ts, 119, 78)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 121, 21)) type T1 = MaybeTrue<{ b: false }>; // "no" ->T1 : Symbol(T1, Decl(conditionalTypes2.ts, 151, 33)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 152, 21)) +>T1 : Symbol(T1, Decl(conditionalTypes2.ts, 121, 33)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 122, 21)) type T2 = MaybeTrue<{ b: true }>; // "yes" ->T2 : Symbol(T2, Decl(conditionalTypes2.ts, 152, 34)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 153, 21)) +>T2 : Symbol(T2, Decl(conditionalTypes2.ts, 122, 34)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 123, 21)) type T3 = MaybeTrue<{ b: boolean }>; // "yes" ->T3 : Symbol(T3, Decl(conditionalTypes2.ts, 153, 33)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 154, 21)) +>T3 : Symbol(T3, Decl(conditionalTypes2.ts, 123, 33)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 124, 21)) // Repro from #28824 type Union = 'a' | 'b'; ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) type Product = { f1: A, f2: B}; ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 159, 13)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 159, 29)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 159, 36)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 159, 13)) ->f2 : Symbol(f2, Decl(conditionalTypes2.ts, 159, 43)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 159, 29)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 129, 13)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 129, 29)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 129, 36)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 129, 13)) +>f2 : Symbol(f2, Decl(conditionalTypes2.ts, 129, 43)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 129, 29)) type ProductUnion = Product<'a', 0> | Product<'b', 1>; ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) // {a: "b"; b: "a"} type UnionComplement = { ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) [K in Union]: Exclude ->K : Symbol(K, Decl(conditionalTypes2.ts, 164, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 134, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 164, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 134, 3)) }; type UCA = UnionComplement['a']; ->UCA : Symbol(UCA, Decl(conditionalTypes2.ts, 165, 2)) ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) +>UCA : Symbol(UCA, Decl(conditionalTypes2.ts, 135, 2)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) type UCB = UnionComplement['b']; ->UCB : Symbol(UCB, Decl(conditionalTypes2.ts, 166, 32)) ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) +>UCB : Symbol(UCB, Decl(conditionalTypes2.ts, 136, 32)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) // {a: "a"; b: "b"} type UnionComplementComplement = { ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) [K in Union]: Exclude> ->K : Symbol(K, Decl(conditionalTypes2.ts, 171, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 141, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 171, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 141, 3)) }; type UCCA = UnionComplementComplement['a']; ->UCCA : Symbol(UCCA, Decl(conditionalTypes2.ts, 172, 2)) ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) +>UCCA : Symbol(UCCA, Decl(conditionalTypes2.ts, 142, 2)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) type UCCB = UnionComplementComplement['b']; ->UCCB : Symbol(UCCB, Decl(conditionalTypes2.ts, 173, 43)) ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) +>UCCB : Symbol(UCCB, Decl(conditionalTypes2.ts, 143, 43)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) // {a: Product<'b', 1>; b: Product<'a', 0>} type ProductComplement = { ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) [K in Union]: Exclude ->K : Symbol(K, Decl(conditionalTypes2.ts, 178, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 148, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 178, 39)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 178, 3)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 148, 39)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 148, 3)) }; type PCA = ProductComplement['a']; ->PCA : Symbol(PCA, Decl(conditionalTypes2.ts, 179, 2)) ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) +>PCA : Symbol(PCA, Decl(conditionalTypes2.ts, 149, 2)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) type PCB = ProductComplement['b']; ->PCB : Symbol(PCB, Decl(conditionalTypes2.ts, 180, 34)) ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) +>PCB : Symbol(PCB, Decl(conditionalTypes2.ts, 150, 34)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) // {a: Product<'a', 0>; b: Product<'b', 1>} type ProductComplementComplement = { ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) [K in Union]: Exclude> ->K : Symbol(K, Decl(conditionalTypes2.ts, 185, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 155, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 185, 61)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 185, 3)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 155, 61)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 155, 3)) }; type PCCA = ProductComplementComplement['a']; ->PCCA : Symbol(PCCA, Decl(conditionalTypes2.ts, 186, 2)) ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) +>PCCA : Symbol(PCCA, Decl(conditionalTypes2.ts, 156, 2)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) type PCCB = ProductComplementComplement['b']; ->PCCB : Symbol(PCCB, Decl(conditionalTypes2.ts, 187, 45)) ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) +>PCCB : Symbol(PCCB, Decl(conditionalTypes2.ts, 157, 45)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) + +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +>MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 162, 15)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 162, 15)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 162, 39)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 162, 39)) + +function oops(arg: MyElement): MyElement { +>oops : Symbol(oops, Decl(conditionalTypes2.ts, 162, 56)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 163, 16)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 163, 30)) +>MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) +>MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 163, 16)) + + return arg; // Unsound, should be error +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 163, 30)) +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +>MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 167, 16)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 167, 16)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 167, 40)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 167, 48)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 167, 40)) + +function oops2(arg: MyAcceptor): MyAcceptor { +>oops2 : Symbol(oops2, Decl(conditionalTypes2.ts, 167, 72)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 168, 17)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 168, 31)) +>MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 168, 17)) +>MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) + + return arg; // Unsound, should be error +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 168, 31)) +} + +type Dist = T extends number ? number : string; +>Dist : Symbol(Dist, Decl(conditionalTypes2.ts, 170, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 172, 10)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 172, 10)) + +type Aux = A["a"] extends number ? number : string; +>Aux : Symbol(Aux, Decl(conditionalTypes2.ts, 172, 50)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 173, 9)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 173, 20)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 173, 9)) + +type Nondist = Aux<{a: T}>; +>Nondist : Symbol(Nondist, Decl(conditionalTypes2.ts, 173, 77)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 174, 13)) +>Aux : Symbol(Aux, Decl(conditionalTypes2.ts, 172, 50)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 174, 23)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 174, 13)) + +function oops3(arg: Dist): Nondist { +>oops3 : Symbol(oops3, Decl(conditionalTypes2.ts, 174, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 175, 18)) +>Dist : Symbol(Dist, Decl(conditionalTypes2.ts, 170, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) +>Nondist : Symbol(Nondist, Decl(conditionalTypes2.ts, 173, 77)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) + + return arg; // Unsound, should be error +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 175, 18)) +} diff --git a/tests/baselines/reference/conditionalTypes2.types b/tests/baselines/reference/conditionalTypes2.types index aac6ba47475..3cffe6ab48e 100644 --- a/tests/baselines/reference/conditionalTypes2.types +++ b/tests/baselines/reference/conditionalTypes2.types @@ -1,4 +1,6 @@ === tests/cases/conformance/types/conditional/conditionalTypes2.ts === +// #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; >foo : T extends string ? T : number @@ -19,7 +21,7 @@ function f1(a: Covariant, b: Covariant) { >a : Covariant >b : Covariant - a = b; + a = b; // Error >a = b : Covariant >a : Covariant >b : Covariant @@ -40,7 +42,7 @@ function f2(a: Contravariant, b: Contravariant) { >a : Contravariant >b : Contravariant - b = a; + b = a; // Error >b = a : Contravariant >b : Contravariant >a : Contravariant @@ -207,71 +209,6 @@ function f21(x: Extract, Bar>, y: Extract, z: E >z : Extract2 } -// Repros from #22860 - -class Opt { ->Opt : Opt - - toVector(): Vector { ->toVector : () => Vector - - return undefined; ->undefined : any ->undefined : undefined - } -} - -interface Seq { - tail(): Opt>; ->tail : () => Opt> -} - -class Vector implements Seq { ->Vector : Vector - - tail(): Opt> { ->tail : () => Opt> - - return undefined; ->undefined : any ->undefined : undefined - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; ->partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } ->predicate : (v: T) => v is U ->v : T - - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; ->partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } ->predicate : (x: T) => boolean ->x : T - - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { ->partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } ->predicate : (v: T) => boolean ->v : T - - return undefined; ->undefined : any ->undefined : undefined - } -} - -interface A1 { - bat: B1>; ->bat : B1> -} - -interface B1 extends A1 { - bat: B1>; ->bat : B1> - - boom: T extends any ? true : true ->boom : T extends any ? true : true ->true : true ->true : true -} - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -431,3 +368,47 @@ type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; >PCCB : Product<"b", 1> +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +>MyElement : MyElement + +function oops(arg: MyElement): MyElement { +>oops : (arg: MyElement) => MyElement +>arg : MyElement + + return arg; // Unsound, should be error +>arg : MyElement +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +>MyAcceptor : MyAcceptor +>arg : E + +function oops2(arg: MyAcceptor): MyAcceptor { +>oops2 : (arg: MyAcceptor) => MyAcceptor +>arg : MyAcceptor + + return arg; // Unsound, should be error +>arg : MyAcceptor +} + +type Dist = T extends number ? number : string; +>Dist : Dist + +type Aux = A["a"] extends number ? number : string; +>Aux : Aux +>a : unknown + +type Nondist = Aux<{a: T}>; +>Nondist : Aux<{ a: T; }> +>a : T + +function oops3(arg: Dist): Nondist { +>oops3 : (arg: Dist) => Aux<{ a: T; }> +>arg : Dist + + return arg; // Unsound, should be error +>arg : Dist +} + diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt index d2246fbfd84..2b94b57f462 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt +++ b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error TS2345: Argument of type '(a: number, b: any, ...x: any[]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. +tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error TS2345: Argument of type '(a: number, b: T[0], ...x: T[number][]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. Types of parameters 'b' and 'args' are incompatible. - Type 'T' is not assignable to type '[any, ...any[]]'. - Property '0' is missing in type 'any[]' but required in type '[any, ...any[]]'. + Type 'T' is not assignable to type '[T[0], ...T[number][]]'. + Property '0' is missing in type 'any[]' but required in type '[T[0], ...T[number][]]'. ==== tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts (1 errors) ==== @@ -62,10 +62,10 @@ tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error f((a, ...x) => {}); f((a, b, ...x) => {}); ~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(a: number, b: any, ...x: any[]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. +!!! error TS2345: Argument of type '(a: number, b: T[0], ...x: T[number][]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. !!! error TS2345: Types of parameters 'b' and 'args' are incompatible. -!!! error TS2345: Type 'T' is not assignable to type '[any, ...any[]]'. -!!! error TS2345: Property '0' is missing in type 'any[]' but required in type '[any, ...any[]]'. +!!! error TS2345: Type 'T' is not assignable to type '[T[0], ...T[number][]]'. +!!! error TS2345: Property '0' is missing in type 'any[]' but required in type '[T[0], ...T[number][]]'. } // Repro from #25288 @@ -79,4 +79,18 @@ tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error (function foo(...rest){}(1, '')); take(function(...rest){}); + + // Repro from #29833 + + type ArgsUnion = [number, string] | [number, Error]; + type TupleUnionFunc = (...params: ArgsUnion) => number; + + const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { + return num; + }; + + const funcUnionTupleRest: TupleUnionFunc = (...params) => { + const [num, strOrErr] = params; + return num; + }; \ No newline at end of file diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.js b/tests/baselines/reference/restTuplesFromContextualTypes.js index 3db6c53f384..34e75fcea6e 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.js +++ b/tests/baselines/reference/restTuplesFromContextualTypes.js @@ -68,6 +68,20 @@ declare function take(cb: (a: number, b: string) => void): void; (function foo(...rest){}(1, '')); take(function(...rest){}); + +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +type TupleUnionFunc = (...params: ArgsUnion) => number; + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { + return num; +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { + const [num, strOrErr] = params; + return num; +}; //// [restTuplesFromContextualTypes.js] @@ -274,6 +288,17 @@ take(function () { rest[_i] = arguments[_i]; } }); +var funcUnionTupleNoRest = function (num, strOrErr) { + return num; +}; +var funcUnionTupleRest = function () { + var params = []; + for (var _i = 0; _i < arguments.length; _i++) { + params[_i] = arguments[_i]; + } + var num = params[0], strOrErr = params[1]; + return num; +}; //// [restTuplesFromContextualTypes.d.ts] @@ -286,3 +311,7 @@ declare function f3(cb: (x: number, ...args: typeof t3) => void): void; declare function f4(t: T): void; declare var tuple: [number, string]; declare function take(cb: (a: number, b: string) => void): void; +declare type ArgsUnion = [number, string] | [number, Error]; +declare type TupleUnionFunc = (...params: ArgsUnion) => number; +declare const funcUnionTupleNoRest: TupleUnionFunc; +declare const funcUnionTupleRest: TupleUnionFunc; diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.symbols b/tests/baselines/reference/restTuplesFromContextualTypes.symbols index d9b2310b5e2..c58e8cabcae 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.symbols +++ b/tests/baselines/reference/restTuplesFromContextualTypes.symbols @@ -265,3 +265,40 @@ take(function(...rest){}); >take : Symbol(take, Decl(restTuplesFromContextualTypes.ts, 61, 33)) >rest : Symbol(rest, Decl(restTuplesFromContextualTypes.ts, 68, 14)) +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +>ArgsUnion : Symbol(ArgsUnion, Decl(restTuplesFromContextualTypes.ts, 68, 26)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +type TupleUnionFunc = (...params: ArgsUnion) => number; +>TupleUnionFunc : Symbol(TupleUnionFunc, Decl(restTuplesFromContextualTypes.ts, 72, 52)) +>params : Symbol(params, Decl(restTuplesFromContextualTypes.ts, 73, 23)) +>ArgsUnion : Symbol(ArgsUnion, Decl(restTuplesFromContextualTypes.ts, 68, 26)) + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { +>funcUnionTupleNoRest : Symbol(funcUnionTupleNoRest, Decl(restTuplesFromContextualTypes.ts, 75, 5)) +>TupleUnionFunc : Symbol(TupleUnionFunc, Decl(restTuplesFromContextualTypes.ts, 72, 52)) +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 75, 46)) +>strOrErr : Symbol(strOrErr, Decl(restTuplesFromContextualTypes.ts, 75, 50)) + + return num; +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 75, 46)) + +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { +>funcUnionTupleRest : Symbol(funcUnionTupleRest, Decl(restTuplesFromContextualTypes.ts, 79, 5)) +>TupleUnionFunc : Symbol(TupleUnionFunc, Decl(restTuplesFromContextualTypes.ts, 72, 52)) +>params : Symbol(params, Decl(restTuplesFromContextualTypes.ts, 79, 44)) + + const [num, strOrErr] = params; +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 80, 9)) +>strOrErr : Symbol(strOrErr, Decl(restTuplesFromContextualTypes.ts, 80, 13)) +>params : Symbol(params, Decl(restTuplesFromContextualTypes.ts, 79, 44)) + + return num; +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 80, 9)) + +}; + diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.types b/tests/baselines/reference/restTuplesFromContextualTypes.types index ee63057b9eb..c282dbbae31 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.types +++ b/tests/baselines/reference/restTuplesFromContextualTypes.types @@ -332,8 +332,8 @@ function f4(t: T) { f((...x) => {}); >f((...x) => {}) : void >f : (cb: (x: number, ...args: T) => void) => void ->(...x) => {} : (x: number, ...args: any[]) => void ->x : [number, ...any[]] +>(...x) => {} : (x: number, ...args: T[number][]) => void +>x : [number, ...T[number][]] f((a, ...x) => {}); >f((a, ...x) => {}) : void @@ -345,10 +345,10 @@ function f4(t: T) { f((a, b, ...x) => {}); >f((a, b, ...x) => {}) : void >f : (cb: (x: number, ...args: T) => void) => void ->(a, b, ...x) => {} : (a: number, b: any, ...x: any[]) => void +>(a, b, ...x) => {} : (a: number, b: T[0], ...x: T[number][]) => void >a : number ->b : any ->x : any[] +>b : T[0] +>x : T[number][] } // Repro from #25288 @@ -389,3 +389,38 @@ take(function(...rest){}); >function(...rest){} : (a: number, b: string) => void >rest : [number, string] +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +>ArgsUnion : ArgsUnion + +type TupleUnionFunc = (...params: ArgsUnion) => number; +>TupleUnionFunc : TupleUnionFunc +>params : ArgsUnion + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { +>funcUnionTupleNoRest : TupleUnionFunc +>(num, strOrErr) => { return num;} : (num: number, strOrErr: string | Error) => number +>num : number +>strOrErr : string | Error + + return num; +>num : number + +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { +>funcUnionTupleRest : TupleUnionFunc +>(...params) => { const [num, strOrErr] = params; return num;} : (...params: ArgsUnion) => number +>params : ArgsUnion + + const [num, strOrErr] = params; +>num : number +>strOrErr : string | Error +>params : ArgsUnion + + return num; +>num : number + +}; + diff --git a/tests/cases/conformance/types/conditional/conditionalTypes2.ts b/tests/cases/conformance/types/conditional/conditionalTypes2.ts index 4b65b5ddeb2..5d73c58fe7f 100644 --- a/tests/cases/conformance/types/conditional/conditionalTypes2.ts +++ b/tests/cases/conformance/types/conditional/conditionalTypes2.ts @@ -1,6 +1,8 @@ // @strict: true // @declaration: true +// #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; } @@ -14,13 +16,13 @@ interface Invariant { } function f1(a: Covariant, b: Covariant) { - a = b; + a = b; // Error b = a; // Error } function f2(a: Contravariant, b: Contravariant) { a = b; // Error - b = a; + b = a; // Error } function f3(a: Invariant, b: Invariant) { @@ -78,38 +80,6 @@ function f21(x: Extract, Bar>, y: Extract, z: E fooBat(z); // Error } -// Repros from #22860 - -class Opt { - toVector(): Vector { - return undefined; - } -} - -interface Seq { - tail(): Opt>; -} - -class Vector implements Seq { - tail(): Opt> { - return undefined; - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { - return undefined; - } -} - -interface A1 { - bat: B1>; -} - -interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true -} - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -190,3 +160,22 @@ type ProductComplementComplement = { }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; + +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +function oops(arg: MyElement): MyElement { + return arg; // Unsound, should be error +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +function oops2(arg: MyAcceptor): MyAcceptor { + return arg; // Unsound, should be error +} + +type Dist = T extends number ? number : string; +type Aux = A["a"] extends number ? number : string; +type Nondist = Aux<{a: T}>; +function oops3(arg: Dist): Nondist { + return arg; // Unsound, should be error +} diff --git a/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts b/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts index 84bf81195b0..d5623a000a2 100644 --- a/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts +++ b/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts @@ -70,3 +70,17 @@ declare function take(cb: (a: number, b: string) => void): void; (function foo(...rest){}(1, '')); take(function(...rest){}); + +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +type TupleUnionFunc = (...params: ArgsUnion) => number; + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { + return num; +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { + const [num, strOrErr] = params; + return num; +}; diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter index 40bdb4eadab..6b9706810b5 160000 --- a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -1 +1 @@ -Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6 +Subproject commit 6b9706810b55af326a93b9aa59cb17815a30bb32 diff --git a/tests/cases/user/prettier/prettier b/tests/cases/user/prettier/prettier index 67f1c4877ee..6e0de081223 160000 --- a/tests/cases/user/prettier/prettier +++ b/tests/cases/user/prettier/prettier @@ -1 +1 @@ -Subproject commit 67f1c4877ee1090b66d468a847caccca411a6f82 +Subproject commit 6e0de0812231c3a48387d398d092418749aa39f1 diff --git a/tests/cases/user/webpack/webpack b/tests/cases/user/webpack/webpack index 10282ea2064..a28f44f6132 160000 --- a/tests/cases/user/webpack/webpack +++ b/tests/cases/user/webpack/webpack @@ -1 +1 @@ -Subproject commit 10282ea20648b465caec6448849f24fc34e1ba3e +Subproject commit a28f44f613276446fb764dec7fab38b7cff8a07c