mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Add tests
This commit is contained in:
parent
57351e898e
commit
35f1fcbe85
@ -31,6 +31,13 @@ function f3<T>(x: Partial<T>[keyof T], y: NonNullable<Partial<T>[keyof T]>) {
|
||||
y = x; // Error
|
||||
}
|
||||
|
||||
function f4<T extends { x: string | undefined }>(x: T["x"], y: NonNullable<T["x"]>) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
let s1: string = x; // Error
|
||||
let s2: string = y;
|
||||
}
|
||||
|
||||
type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean };
|
||||
|
||||
type T10 = Diff<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
@ -42,8 +49,8 @@ type T13 = Filter<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } |
|
||||
type T14 = Diff<Options, { q: "a" }>; // Options
|
||||
type T15 = Filter<Options, { q: "a" }>; // never
|
||||
|
||||
declare function f4<T extends Options, K extends string>(p: K): Filter<T, { k: K }>;
|
||||
let x0 = f4("a"); // { k: "a", a: number }
|
||||
declare function f5<T extends Options, K extends string>(p: K): Filter<T, { k: K }>;
|
||||
let x0 = f5("a"); // { k: "a", a: number }
|
||||
|
||||
type OptionsOfKind<K extends Options["k"]> = Filter<Options, { k: K }>;
|
||||
|
||||
@ -256,3 +263,20 @@ function f33<T, U>() {
|
||||
var z: T1;
|
||||
var z: T2;
|
||||
}
|
||||
|
||||
// Repro from #21823
|
||||
|
||||
type T90<T> = T extends 0 ? 0 : () => 0;
|
||||
type T91<T> = T extends 0 ? 0 : () => 0;
|
||||
const f40 = <U>(a: T90<U>): T91<U> => a;
|
||||
const f41 = <U>(a: T91<U>): T90<U> => a;
|
||||
|
||||
type T92<T> = T extends () => 0 ? () => 1 : () => 2;
|
||||
type T93<T> = T extends () => 0 ? () => 1 : () => 2;
|
||||
const f42 = <U>(a: T92<U>): T93<U> => a;
|
||||
const f43 = <U>(a: T93<U>): T92<U> => a;
|
||||
|
||||
type T94<T> = T extends string ? true : 42;
|
||||
type T95<T> = T extends string ? boolean : number;
|
||||
const f44 = <U>(value: T94<U>): T95<U> => value;
|
||||
const f45 = <U>(value: T95<U>): T94<U> => value; // Error
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user