Skip to content

Commit ce2dea9

Browse files
committed
Accept new baselines
1 parent 59355cb commit ce2dea9

4 files changed

+146
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts(10,9): error TS2322: Type 'T' is not assignable to type 'object'.
2+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts(11,9): error TS2322: Type 'T' is not assignable to type 'object | U'.
3+
Type 'T' is not assignable to type 'U'.
4+
5+
6+
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts (2 errors) ====
7+
// Repros from #23800
8+
9+
type A<T, V> = { [P in keyof T]: T[P] extends V ? 1 : 0; };
10+
type B<T, V> = { [P in keyof T]: T[P] extends V | object ? 1 : 0; };
11+
12+
type a = A<{ a: 0 | 1 }, 0>; // { a: 0; }
13+
type b = B<{ a: 0 | 1 }, 0>; // { a: 0; }
14+
15+
function foo<T, U>(x: T) {
16+
let a: object = x; // Error
17+
~
18+
!!! error TS2322: Type 'T' is not assignable to type 'object'.
19+
let b: U | object = x; // Error
20+
~
21+
!!! error TS2322: Type 'T' is not assignable to type 'object | U'.
22+
!!! error TS2322: Type 'T' is not assignable to type 'U'.
23+
}
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [nonPrimitiveAndTypeVariables.ts]
2+
// Repros from #23800
3+
4+
type A<T, V> = { [P in keyof T]: T[P] extends V ? 1 : 0; };
5+
type B<T, V> = { [P in keyof T]: T[P] extends V | object ? 1 : 0; };
6+
7+
type a = A<{ a: 0 | 1 }, 0>; // { a: 0; }
8+
type b = B<{ a: 0 | 1 }, 0>; // { a: 0; }
9+
10+
function foo<T, U>(x: T) {
11+
let a: object = x; // Error
12+
let b: U | object = x; // Error
13+
}
14+
15+
16+
//// [nonPrimitiveAndTypeVariables.js]
17+
"use strict";
18+
// Repros from #23800
19+
function foo(x) {
20+
var a = x; // Error
21+
var b = x; // Error
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts ===
2+
// Repros from #23800
3+
4+
type A<T, V> = { [P in keyof T]: T[P] extends V ? 1 : 0; };
5+
>A : Symbol(A, Decl(nonPrimitiveAndTypeVariables.ts, 0, 0))
6+
>T : Symbol(T, Decl(nonPrimitiveAndTypeVariables.ts, 2, 7))
7+
>V : Symbol(V, Decl(nonPrimitiveAndTypeVariables.ts, 2, 9))
8+
>P : Symbol(P, Decl(nonPrimitiveAndTypeVariables.ts, 2, 18))
9+
>T : Symbol(T, Decl(nonPrimitiveAndTypeVariables.ts, 2, 7))
10+
>T : Symbol(T, Decl(nonPrimitiveAndTypeVariables.ts, 2, 7))
11+
>P : Symbol(P, Decl(nonPrimitiveAndTypeVariables.ts, 2, 18))
12+
>V : Symbol(V, Decl(nonPrimitiveAndTypeVariables.ts, 2, 9))
13+
14+
type B<T, V> = { [P in keyof T]: T[P] extends V | object ? 1 : 0; };
15+
>B : Symbol(B, Decl(nonPrimitiveAndTypeVariables.ts, 2, 59))
16+
>T : Symbol(T, Decl(nonPrimitiveAndTypeVariables.ts, 3, 7))
17+
>V : Symbol(V, Decl(nonPrimitiveAndTypeVariables.ts, 3, 9))
18+
>P : Symbol(P, Decl(nonPrimitiveAndTypeVariables.ts, 3, 18))
19+
>T : Symbol(T, Decl(nonPrimitiveAndTypeVariables.ts, 3, 7))
20+
>T : Symbol(T, Decl(nonPrimitiveAndTypeVariables.ts, 3, 7))
21+
>P : Symbol(P, Decl(nonPrimitiveAndTypeVariables.ts, 3, 18))
22+
>V : Symbol(V, Decl(nonPrimitiveAndTypeVariables.ts, 3, 9))
23+
24+
type a = A<{ a: 0 | 1 }, 0>; // { a: 0; }
25+
>a : Symbol(a, Decl(nonPrimitiveAndTypeVariables.ts, 3, 68))
26+
>A : Symbol(A, Decl(nonPrimitiveAndTypeVariables.ts, 0, 0))
27+
>a : Symbol(a, Decl(nonPrimitiveAndTypeVariables.ts, 5, 12))
28+
29+
type b = B<{ a: 0 | 1 }, 0>; // { a: 0; }
30+
>b : Symbol(b, Decl(nonPrimitiveAndTypeVariables.ts, 5, 28))
31+
>B : Symbol(B, Decl(nonPrimitiveAndTypeVariables.ts, 2, 59))
32+
>a : Symbol(a, Decl(nonPrimitiveAndTypeVariables.ts, 6, 12))
33+
34+
function foo<T, U>(x: T) {
35+
>foo : Symbol(foo, Decl(nonPrimitiveAndTypeVariables.ts, 6, 28))
36+
>T : Symbol(T, Decl(nonPrimitiveAndTypeVariables.ts, 8, 13))
37+
>U : Symbol(U, Decl(nonPrimitiveAndTypeVariables.ts, 8, 15))
38+
>x : Symbol(x, Decl(nonPrimitiveAndTypeVariables.ts, 8, 19))
39+
>T : Symbol(T, Decl(nonPrimitiveAndTypeVariables.ts, 8, 13))
40+
41+
let a: object = x; // Error
42+
>a : Symbol(a, Decl(nonPrimitiveAndTypeVariables.ts, 9, 7))
43+
>x : Symbol(x, Decl(nonPrimitiveAndTypeVariables.ts, 8, 19))
44+
45+
let b: U | object = x; // Error
46+
>b : Symbol(b, Decl(nonPrimitiveAndTypeVariables.ts, 10, 7))
47+
>U : Symbol(U, Decl(nonPrimitiveAndTypeVariables.ts, 8, 15))
48+
>x : Symbol(x, Decl(nonPrimitiveAndTypeVariables.ts, 8, 19))
49+
}
50+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAndTypeVariables.ts ===
2+
// Repros from #23800
3+
4+
type A<T, V> = { [P in keyof T]: T[P] extends V ? 1 : 0; };
5+
>A : A<T, V>
6+
>T : T
7+
>V : V
8+
>P : P
9+
>T : T
10+
>T : T
11+
>P : P
12+
>V : V
13+
14+
type B<T, V> = { [P in keyof T]: T[P] extends V | object ? 1 : 0; };
15+
>B : B<T, V>
16+
>T : T
17+
>V : V
18+
>P : P
19+
>T : T
20+
>T : T
21+
>P : P
22+
>V : V
23+
24+
type a = A<{ a: 0 | 1 }, 0>; // { a: 0; }
25+
>a : A<{ a: 0 | 1; }, 0>
26+
>A : A<T, V>
27+
>a : 0 | 1
28+
29+
type b = B<{ a: 0 | 1 }, 0>; // { a: 0; }
30+
>b : B<{ a: 0 | 1; }, 0>
31+
>B : B<T, V>
32+
>a : 0 | 1
33+
34+
function foo<T, U>(x: T) {
35+
>foo : <T, U>(x: T) => void
36+
>T : T
37+
>U : U
38+
>x : T
39+
>T : T
40+
41+
let a: object = x; // Error
42+
>a : object
43+
>x : T
44+
45+
let b: U | object = x; // Error
46+
>b : object | U
47+
>U : U
48+
>x : T
49+
}
50+

0 commit comments

Comments
 (0)