Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an extra test case for deferred conditional types #53067

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tests/baselines/reference/deferredConditionalTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,19 @@ type FilteredValuesMatchNever<O extends object>
= Equals<Values<FilterByStringValue<[O]>>, never>

type FilteredRes1 = FilteredValuesMatchNever<[]>


// repro from #46761

type Bit = 0 | 1;

type AndBit<A extends Bit, B extends Bit> = [A, B] extends [1, 1] ? 1 : 0;

type TestBit<A extends Bit, B extends Bit> = AndBit<
A extends 1 ? 0 : 1,
B extends 1 ? 0 : 1
>;

type TestBitRes = TestBit<1, 1>;

//// [deferredConditionalTypes.js]
"use strict";
34 changes: 34 additions & 0 deletions tests/baselines/reference/deferredConditionalTypes.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,37 @@ type FilteredRes1 = FilteredValuesMatchNever<[]>
>FilteredRes1 : Symbol(FilteredRes1, Decl(deferredConditionalTypes.ts, 37, 51))
>FilteredValuesMatchNever : Symbol(FilteredValuesMatchNever, Decl(deferredConditionalTypes.ts, 34, 1))

// repro from #46761

type Bit = 0 | 1;
>Bit : Symbol(Bit, Decl(deferredConditionalTypes.ts, 39, 48))

type AndBit<A extends Bit, B extends Bit> = [A, B] extends [1, 1] ? 1 : 0;
>AndBit : Symbol(AndBit, Decl(deferredConditionalTypes.ts, 43, 17))
>A : Symbol(A, Decl(deferredConditionalTypes.ts, 45, 12))
>Bit : Symbol(Bit, Decl(deferredConditionalTypes.ts, 39, 48))
>B : Symbol(B, Decl(deferredConditionalTypes.ts, 45, 26))
>Bit : Symbol(Bit, Decl(deferredConditionalTypes.ts, 39, 48))
>A : Symbol(A, Decl(deferredConditionalTypes.ts, 45, 12))
>B : Symbol(B, Decl(deferredConditionalTypes.ts, 45, 26))

type TestBit<A extends Bit, B extends Bit> = AndBit<
>TestBit : Symbol(TestBit, Decl(deferredConditionalTypes.ts, 45, 74))
>A : Symbol(A, Decl(deferredConditionalTypes.ts, 47, 13))
>Bit : Symbol(Bit, Decl(deferredConditionalTypes.ts, 39, 48))
>B : Symbol(B, Decl(deferredConditionalTypes.ts, 47, 27))
>Bit : Symbol(Bit, Decl(deferredConditionalTypes.ts, 39, 48))
>AndBit : Symbol(AndBit, Decl(deferredConditionalTypes.ts, 43, 17))

A extends 1 ? 0 : 1,
>A : Symbol(A, Decl(deferredConditionalTypes.ts, 47, 13))

B extends 1 ? 0 : 1
>B : Symbol(B, Decl(deferredConditionalTypes.ts, 47, 27))

>;

type TestBitRes = TestBit<1, 1>;
>TestBitRes : Symbol(TestBitRes, Decl(deferredConditionalTypes.ts, 50, 2))
>TestBit : Symbol(TestBit, Decl(deferredConditionalTypes.ts, 45, 74))

18 changes: 18 additions & 0 deletions tests/baselines/reference/deferredConditionalTypes.types
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,21 @@ type FilteredValuesMatchNever<O extends object>
type FilteredRes1 = FilteredValuesMatchNever<[]>
>FilteredRes1 : true

// repro from #46761

type Bit = 0 | 1;
>Bit : 0 | 1

type AndBit<A extends Bit, B extends Bit> = [A, B] extends [1, 1] ? 1 : 0;
>AndBit : AndBit<A, B>

type TestBit<A extends Bit, B extends Bit> = AndBit<
>TestBit : TestBit<A, B>

A extends 1 ? 0 : 1,
B extends 1 ? 0 : 1
>;

type TestBitRes = TestBit<1, 1>;
>TestBitRes : 0

13 changes: 13 additions & 0 deletions tests/cases/compiler/deferredConditionalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,16 @@ type FilteredValuesMatchNever<O extends object>
= Equals<Values<FilterByStringValue<[O]>>, never>

type FilteredRes1 = FilteredValuesMatchNever<[]>

// repro from #46761

type Bit = 0 | 1;

type AndBit<A extends Bit, B extends Bit> = [A, B] extends [1, 1] ? 1 : 0;

type TestBit<A extends Bit, B extends Bit> = AndBit<
A extends 1 ? 0 : 1,
B extends 1 ? 0 : 1
>;

type TestBitRes = TestBit<1, 1>;