mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Accept new baselines
This commit is contained in:
@@ -58,9 +58,10 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(156,5): error TS2
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf<T>'.
|
||||
Type 'string | number' is not assignable to type 'ZeroOf<T>'.
|
||||
Type 'string' is not assignable to type 'ZeroOf<T>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(247,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'T1', but here has type 'Foo<T & U>'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/conditional/conditionalTypes1.ts (18 errors) ====
|
||||
==== tests/cases/conformance/types/conditional/conditionalTypes1.ts (19 errors) ====
|
||||
type Diff<T, U> = T extends U ? never : T;
|
||||
type Filter<T, U> = T extends U ? T : never;
|
||||
type NonNullable<T> = Diff<T, null | undefined>;
|
||||
@@ -364,4 +365,36 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2
|
||||
type T81 = Eq2<true, false>; // false
|
||||
type T82 = Eq2<false, true>; // false
|
||||
type T83 = Eq2<false, false>; // true
|
||||
|
||||
// Repro from #21756
|
||||
|
||||
type Foo<T> = T extends string ? boolean : number;
|
||||
type Bar<T> = T extends string ? boolean : number;
|
||||
const convert = <U>(value: Foo<U>): Bar<U> => value;
|
||||
|
||||
type Baz<T> = Foo<T>;
|
||||
const convert2 = <T>(value: Foo<T>): Baz<T> => value;
|
||||
|
||||
function f31<T>() {
|
||||
type T1 = T extends string ? boolean : number;
|
||||
type T2 = T extends string ? boolean : number;
|
||||
var x: T1;
|
||||
var x: T2;
|
||||
}
|
||||
|
||||
function f32<T, U>() {
|
||||
type T1 = T & U extends string ? boolean : number;
|
||||
type T2 = Foo<T & U>;
|
||||
var z: T1;
|
||||
var z: T2; // Error, T2 is distributive, T1 isn't
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'T1', but here has type 'Foo<T & U>'.
|
||||
}
|
||||
|
||||
function f33<T, U>() {
|
||||
type T1 = Foo<T & U>;
|
||||
type T2 = Bar<T & U>;
|
||||
var z: T1;
|
||||
var z: T2;
|
||||
}
|
||||
|
||||
@@ -224,6 +224,36 @@ type T80 = Eq2<true, true>; // true
|
||||
type T81 = Eq2<true, false>; // false
|
||||
type T82 = Eq2<false, true>; // false
|
||||
type T83 = Eq2<false, false>; // true
|
||||
|
||||
// Repro from #21756
|
||||
|
||||
type Foo<T> = T extends string ? boolean : number;
|
||||
type Bar<T> = T extends string ? boolean : number;
|
||||
const convert = <U>(value: Foo<U>): Bar<U> => value;
|
||||
|
||||
type Baz<T> = Foo<T>;
|
||||
const convert2 = <T>(value: Foo<T>): Baz<T> => value;
|
||||
|
||||
function f31<T>() {
|
||||
type T1 = T extends string ? boolean : number;
|
||||
type T2 = T extends string ? boolean : number;
|
||||
var x: T1;
|
||||
var x: T2;
|
||||
}
|
||||
|
||||
function f32<T, U>() {
|
||||
type T1 = T & U extends string ? boolean : number;
|
||||
type T2 = Foo<T & U>;
|
||||
var z: T1;
|
||||
var z: T2; // Error, T2 is distributive, T1 isn't
|
||||
}
|
||||
|
||||
function f33<T, U>() {
|
||||
type T1 = Foo<T & U>;
|
||||
type T2 = Bar<T & U>;
|
||||
var z: T1;
|
||||
var z: T2;
|
||||
}
|
||||
|
||||
|
||||
//// [conditionalTypes1.js]
|
||||
@@ -285,6 +315,20 @@ function f21(x, y) {
|
||||
x = y; // Error
|
||||
y = x; // Error
|
||||
}
|
||||
var convert = function (value) { return value; };
|
||||
var convert2 = function (value) { return value; };
|
||||
function f31() {
|
||||
var x;
|
||||
var x;
|
||||
}
|
||||
function f32() {
|
||||
var z;
|
||||
var z; // Error, T2 is distributive, T1 isn't
|
||||
}
|
||||
function f33() {
|
||||
var z;
|
||||
var z;
|
||||
}
|
||||
|
||||
|
||||
//// [conditionalTypes1.d.ts]
|
||||
@@ -450,3 +494,11 @@ declare type T80 = Eq2<true, true>;
|
||||
declare type T81 = Eq2<true, false>;
|
||||
declare type T82 = Eq2<false, true>;
|
||||
declare type T83 = Eq2<false, false>;
|
||||
declare type Foo<T> = T extends string ? boolean : number;
|
||||
declare type Bar<T> = T extends string ? boolean : number;
|
||||
declare const convert: <U>(value: Foo<U>) => Foo<U>;
|
||||
declare type Baz<T> = Foo<T>;
|
||||
declare const convert2: <T>(value: Foo<T>) => Foo<T>;
|
||||
declare function f31<T>(): void;
|
||||
declare function f32<T, U>(): void;
|
||||
declare function f33<T, U>(): void;
|
||||
|
||||
@@ -852,3 +852,113 @@ type T83 = Eq2<false, false>; // true
|
||||
>T83 : Symbol(T83, Decl(conditionalTypes1.ts, 223, 28))
|
||||
>Eq2 : Symbol(Eq2, Decl(conditionalTypes1.ts, 218, 29))
|
||||
|
||||
// Repro from #21756
|
||||
|
||||
type Foo<T> = T extends string ? boolean : number;
|
||||
>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 224, 29))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 228, 9))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 228, 9))
|
||||
|
||||
type Bar<T> = T extends string ? boolean : number;
|
||||
>Bar : Symbol(Bar, Decl(conditionalTypes1.ts, 228, 50))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 229, 9))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 229, 9))
|
||||
|
||||
const convert = <U>(value: Foo<U>): Bar<U> => value;
|
||||
>convert : Symbol(convert, Decl(conditionalTypes1.ts, 230, 5))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 230, 17))
|
||||
>value : Symbol(value, Decl(conditionalTypes1.ts, 230, 20))
|
||||
>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 224, 29))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 230, 17))
|
||||
>Bar : Symbol(Bar, Decl(conditionalTypes1.ts, 228, 50))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 230, 17))
|
||||
>value : Symbol(value, Decl(conditionalTypes1.ts, 230, 20))
|
||||
|
||||
type Baz<T> = Foo<T>;
|
||||
>Baz : Symbol(Baz, Decl(conditionalTypes1.ts, 230, 52))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 232, 9))
|
||||
>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 224, 29))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 232, 9))
|
||||
|
||||
const convert2 = <T>(value: Foo<T>): Baz<T> => value;
|
||||
>convert2 : Symbol(convert2, Decl(conditionalTypes1.ts, 233, 5))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 233, 18))
|
||||
>value : Symbol(value, Decl(conditionalTypes1.ts, 233, 21))
|
||||
>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 224, 29))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 233, 18))
|
||||
>Baz : Symbol(Baz, Decl(conditionalTypes1.ts, 230, 52))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 233, 18))
|
||||
>value : Symbol(value, Decl(conditionalTypes1.ts, 233, 21))
|
||||
|
||||
function f31<T>() {
|
||||
>f31 : Symbol(f31, Decl(conditionalTypes1.ts, 233, 53))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 235, 13))
|
||||
|
||||
type T1 = T extends string ? boolean : number;
|
||||
>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 235, 19))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 235, 13))
|
||||
|
||||
type T2 = T extends string ? boolean : number;
|
||||
>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 236, 50))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 235, 13))
|
||||
|
||||
var x: T1;
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 238, 7), Decl(conditionalTypes1.ts, 239, 7))
|
||||
>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 235, 19))
|
||||
|
||||
var x: T2;
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 238, 7), Decl(conditionalTypes1.ts, 239, 7))
|
||||
>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 236, 50))
|
||||
}
|
||||
|
||||
function f32<T, U>() {
|
||||
>f32 : Symbol(f32, Decl(conditionalTypes1.ts, 240, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 242, 13))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 242, 15))
|
||||
|
||||
type T1 = T & U extends string ? boolean : number;
|
||||
>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 242, 22))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 242, 13))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 242, 15))
|
||||
|
||||
type T2 = Foo<T & U>;
|
||||
>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 243, 54))
|
||||
>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 224, 29))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 242, 13))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 242, 15))
|
||||
|
||||
var z: T1;
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 245, 7), Decl(conditionalTypes1.ts, 246, 7))
|
||||
>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 242, 22))
|
||||
|
||||
var z: T2; // Error, T2 is distributive, T1 isn't
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 245, 7), Decl(conditionalTypes1.ts, 246, 7))
|
||||
>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 243, 54))
|
||||
}
|
||||
|
||||
function f33<T, U>() {
|
||||
>f33 : Symbol(f33, Decl(conditionalTypes1.ts, 247, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 249, 13))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 249, 15))
|
||||
|
||||
type T1 = Foo<T & U>;
|
||||
>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 249, 22))
|
||||
>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 224, 29))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 249, 13))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 249, 15))
|
||||
|
||||
type T2 = Bar<T & U>;
|
||||
>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 250, 25))
|
||||
>Bar : Symbol(Bar, Decl(conditionalTypes1.ts, 228, 50))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 249, 13))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 249, 15))
|
||||
|
||||
var z: T1;
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 252, 7), Decl(conditionalTypes1.ts, 253, 7))
|
||||
>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 249, 22))
|
||||
|
||||
var z: T2;
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 252, 7), Decl(conditionalTypes1.ts, 253, 7))
|
||||
>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 250, 25))
|
||||
}
|
||||
|
||||
|
||||
@@ -991,3 +991,115 @@ type T83 = Eq2<false, false>; // true
|
||||
>false : false
|
||||
>false : false
|
||||
|
||||
// Repro from #21756
|
||||
|
||||
type Foo<T> = T extends string ? boolean : number;
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
type Bar<T> = T extends string ? boolean : number;
|
||||
>Bar : Bar<T>
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
const convert = <U>(value: Foo<U>): Bar<U> => value;
|
||||
>convert : <U>(value: Foo<U>) => Foo<U>
|
||||
><U>(value: Foo<U>): Bar<U> => value : <U>(value: Foo<U>) => Foo<U>
|
||||
>U : U
|
||||
>value : Foo<U>
|
||||
>Foo : Foo<T>
|
||||
>U : U
|
||||
>Bar : Bar<T>
|
||||
>U : U
|
||||
>value : Foo<U>
|
||||
|
||||
type Baz<T> = Foo<T>;
|
||||
>Baz : Foo<T>
|
||||
>T : T
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
|
||||
const convert2 = <T>(value: Foo<T>): Baz<T> => value;
|
||||
>convert2 : <T>(value: Foo<T>) => Foo<T>
|
||||
><T>(value: Foo<T>): Baz<T> => value : <T>(value: Foo<T>) => Foo<T>
|
||||
>T : T
|
||||
>value : Foo<T>
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
>Baz : Foo<T>
|
||||
>T : T
|
||||
>value : Foo<T>
|
||||
|
||||
function f31<T>() {
|
||||
>f31 : <T>() => void
|
||||
>T : T
|
||||
|
||||
type T1 = T extends string ? boolean : number;
|
||||
>T1 : T extends string ? boolean : number
|
||||
>T : T
|
||||
|
||||
type T2 = T extends string ? boolean : number;
|
||||
>T2 : T extends string ? boolean : number
|
||||
>T : T
|
||||
|
||||
var x: T1;
|
||||
>x : T extends string ? boolean : number
|
||||
>T1 : T extends string ? boolean : number
|
||||
|
||||
var x: T2;
|
||||
>x : T extends string ? boolean : number
|
||||
>T2 : T extends string ? boolean : number
|
||||
}
|
||||
|
||||
function f32<T, U>() {
|
||||
>f32 : <T, U>() => void
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
type T1 = T & U extends string ? boolean : number;
|
||||
>T1 : T & U extends string ? boolean : number
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
type T2 = Foo<T & U>;
|
||||
>T2 : Foo<T & U>
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
var z: T1;
|
||||
>z : T & U extends string ? boolean : number
|
||||
>T1 : T & U extends string ? boolean : number
|
||||
|
||||
var z: T2; // Error, T2 is distributive, T1 isn't
|
||||
>z : T & U extends string ? boolean : number
|
||||
>T2 : Foo<T & U>
|
||||
}
|
||||
|
||||
function f33<T, U>() {
|
||||
>f33 : <T, U>() => void
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
type T1 = Foo<T & U>;
|
||||
>T1 : Foo<T & U>
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
type T2 = Bar<T & U>;
|
||||
>T2 : Foo<T & U>
|
||||
>Bar : Bar<T>
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
var z: T1;
|
||||
>z : Foo<T & U>
|
||||
>T1 : Foo<T & U>
|
||||
|
||||
var z: T2;
|
||||
>z : Foo<T & U>
|
||||
>T2 : Foo<T & U>
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user