mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Accept new baselines
This commit is contained in:
1 parent
eb314d00fc
commit
cdd50d4d96
4 files changed
+2341
No files matched your search
@@ -0,0 +1,337 @@
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(16,5): error TS2322: Type 'T' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(21,5): error TS2322: Type 'T' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
Type 'string | undefined' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
Type 'undefined' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(22,9): error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
Type 'string | undefined' is not assignable to type 'string'.
|
||||
Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(28,5): error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
Type 'T[keyof T] | undefined' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
Type 'undefined' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(100,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(101,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(105,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(111,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(112,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(113,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(114,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(131,10): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(132,5): error TS2542: Index signature in type 'DeepReadonlyArray<Part>' only permits reading.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(133,22): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(134,10): error TS2339: Property 'updatePart' does not exist on type 'DeepReadonlyObject<Part>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(156,5): error TS2322: Type 'ZeroOf<T>' is not assignable to type 'T'.
|
||||
Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'.
|
||||
Type '0' is not assignable to type 'T'.
|
||||
Type '"" | 0' is not assignable to type 'T'.
|
||||
Type '""' is not assignable to type 'T'.
|
||||
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 (18 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>;
|
||||
|
||||
type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
|
||||
type T02 = Diff<string | number | (() => void), Function>; // string | number
|
||||
type T03 = Filter<string | number | (() => void), Function>; // () => void
|
||||
|
||||
type T04 = NonNullable<string | number | undefined>; // string | number
|
||||
type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[]
|
||||
|
||||
function f1<T>(x: T, y: NonNullable<T>) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
}
|
||||
|
||||
function f2<T extends string | undefined>(x: T, y: NonNullable<T>) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
!!! error TS2322: Type 'string | undefined' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
let s1: string = x; // Error
|
||||
~~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'string'.
|
||||
let s2: string = y;
|
||||
}
|
||||
|
||||
function f3<T>(x: Partial<T>[keyof T], y: NonNullable<Partial<T>[keyof T]>) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
}
|
||||
|
||||
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 }
|
||||
type T11 = Filter<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type T12 = Diff<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
type T13 = Filter<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
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 }
|
||||
|
||||
type OptionsOfKind<K extends Options["k"]> = Filter<Options, { k: K }>;
|
||||
|
||||
type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Filter<T, { [P in K]: V }>;
|
||||
|
||||
type T17 = Select<Options, "k", "a" | "b">; // // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type TypeName<T> =
|
||||
T extends string ? "string" :
|
||||
T extends number ? "number" :
|
||||
T extends boolean ? "boolean" :
|
||||
T extends undefined ? "undefined" :
|
||||
T extends Function ? "function" :
|
||||
"object";
|
||||
|
||||
type T20 = TypeName<string | (() => void)>; // "string" | "function"
|
||||
type T21 = TypeName<any>; // "string" | "number" | "boolean" | "undefined" | "function" | "object"
|
||||
type T22 = TypeName<never>; // "string" | "number" | "boolean" | "undefined" | "function" | "object"
|
||||
type T23 = TypeName<{}>; // "object"
|
||||
|
||||
type KnockoutObservable<T> = { object: T };
|
||||
type KnockoutObservableArray<T> = { array: T };
|
||||
|
||||
type KnockedOut<T> = T extends any[] ? KnockoutObservableArray<T[number]> : KnockoutObservable<T>;
|
||||
|
||||
type KnockedOutObj<T> = {
|
||||
[P in keyof T]: KnockedOut<T[P]>;
|
||||
}
|
||||
|
||||
interface Item {
|
||||
id: number;
|
||||
name: string;
|
||||
subitems: string[];
|
||||
}
|
||||
|
||||
type KOItem = KnockedOutObj<Item>;
|
||||
|
||||
interface Part {
|
||||
id: number;
|
||||
name: string;
|
||||
subparts: Part[];
|
||||
updatePart(newName: string): void;
|
||||
}
|
||||
|
||||
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
|
||||
type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
|
||||
|
||||
type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T];
|
||||
type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
||||
|
||||
type T30 = FunctionProperties<Part>;
|
||||
type T31 = NonFunctionProperties<Part>;
|
||||
|
||||
function f7<T>(x: T, y: FunctionProperties<T>, z: NonFunctionProperties<T>) {
|
||||
x = y; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'T'.
|
||||
x = z; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'T'.
|
||||
y = x;
|
||||
y = z; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>'.
|
||||
!!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
z = x;
|
||||
z = y; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>'.
|
||||
!!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
}
|
||||
|
||||
function f8<T>(x: keyof T, y: FunctionPropertyNames<T>, z: NonFunctionPropertyNames<T>) {
|
||||
x = y;
|
||||
x = z;
|
||||
y = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
y = z; // Error
|
||||
~
|
||||
!!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
z = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
z = y; // Error
|
||||
~
|
||||
!!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
}
|
||||
|
||||
type DeepReadonly<T> =
|
||||
T extends any[] ? DeepReadonlyArray<T[number]> :
|
||||
T extends object ? DeepReadonlyObject<T> :
|
||||
T;
|
||||
|
||||
interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {}
|
||||
|
||||
type DeepReadonlyObject<T> = {
|
||||
readonly [P in NonFunctionPropertyNames<T>]: DeepReadonly<T[P]>;
|
||||
};
|
||||
|
||||
function f10(part: DeepReadonly<Part>) {
|
||||
let name: string = part.name;
|
||||
let id: number = part.subparts[0].id;
|
||||
part.id = part.id; // Error
|
||||
~~
|
||||
!!! error TS2540: Cannot assign to 'id' because it is a constant or a read-only property.
|
||||
part.subparts[0] = part.subparts[0]; // Error
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2542: Index signature in type 'DeepReadonlyArray<Part>' only permits reading.
|
||||
part.subparts[0].id = part.subparts[0].id; // Error
|
||||
~~
|
||||
!!! error TS2540: Cannot assign to 'id' because it is a constant or a read-only property.
|
||||
part.updatePart("hello"); // Error
|
||||
~~~~~~~~~~
|
||||
!!! error TS2339: Property 'updatePart' does not exist on type 'DeepReadonlyObject<Part>'.
|
||||
}
|
||||
|
||||
type ZeroOf<T extends number | string | boolean> = T extends number ? 0 : T extends string ? "" : false;
|
||||
|
||||
function zeroOf<T extends number | string | boolean>(value: T) {
|
||||
return <ZeroOf<T>>(typeof value === "number" ? 0 : typeof value === "string" ? "" : false);
|
||||
}
|
||||
|
||||
function f20<T extends string>(n: number, b: boolean, x: number | boolean, y: T) {
|
||||
zeroOf(5); // 0
|
||||
zeroOf("hello"); // ""
|
||||
zeroOf(true); // false
|
||||
zeroOf(n); // 0
|
||||
zeroOf(b); // False
|
||||
zeroOf(x); // 0 | false
|
||||
zeroOf(y); // ZeroOf<T>
|
||||
}
|
||||
|
||||
function f21<T extends number | string>(x: T, y: ZeroOf<T>) {
|
||||
let z1: number | string = y;
|
||||
let z2: 0 | "" = y;
|
||||
x = y; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'ZeroOf<T>' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '0' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '"" | 0' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '""' is not assignable to type 'T'.
|
||||
y = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'ZeroOf<T>'.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'ZeroOf<T>'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'ZeroOf<T>'.
|
||||
}
|
||||
|
||||
type Extends<T, U> = T extends U ? true : false;
|
||||
type If<C extends boolean, T, F> = C extends true ? T : F;
|
||||
type Not<C extends boolean> = If<C, false, true>;
|
||||
type And<A extends boolean, B extends boolean> = If<A, B, false>;
|
||||
type Or<A extends boolean, B extends boolean> = If<A, true, B>;
|
||||
|
||||
type isString<T> = Extends<T, string>;
|
||||
|
||||
type Q1 = isString<number>; // false
|
||||
type Q2 = isString<"abc">; // true
|
||||
type Q3 = isString<any>; // boolean
|
||||
type Q4 = isString<never>; // boolean
|
||||
|
||||
type N1 = Not<false>; // true
|
||||
type N2 = Not<true>; // false
|
||||
type N3 = Not<boolean>; // boolean
|
||||
|
||||
type A1 = And<false, false>; // false
|
||||
type A2 = And<false, true>; // false
|
||||
type A3 = And<true, false>; // false
|
||||
type A4 = And<true, true>; // true
|
||||
type A5 = And<boolean, false>; // false
|
||||
type A6 = And<false, boolean>; // false
|
||||
type A7 = And<boolean, true>; // boolean
|
||||
type A8 = And<true, boolean>; // boolean
|
||||
type A9 = And<boolean, boolean>; // boolean
|
||||
|
||||
type O1 = Or<false, false>; // false
|
||||
type O2 = Or<false, true>; // true
|
||||
type O3 = Or<true, false>; // true
|
||||
type O4 = Or<true, true>; // true
|
||||
type O5 = Or<boolean, false>; // boolean
|
||||
type O6 = Or<false, boolean>; // boolean
|
||||
type O7 = Or<boolean, true>; // true
|
||||
type O8 = Or<true, boolean>; // true
|
||||
type O9 = Or<boolean, boolean>; // boolean
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
//// [conditionalTypes1.ts]
|
||||
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>;
|
||||
|
||||
type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
|
||||
type T02 = Diff<string | number | (() => void), Function>; // string | number
|
||||
type T03 = Filter<string | number | (() => void), Function>; // () => void
|
||||
|
||||
type T04 = NonNullable<string | number | undefined>; // string | number
|
||||
type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[]
|
||||
|
||||
function f1<T>(x: T, y: NonNullable<T>) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
}
|
||||
|
||||
function f2<T extends string | undefined>(x: T, y: NonNullable<T>) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
let s1: string = x; // Error
|
||||
let s2: string = y;
|
||||
}
|
||||
|
||||
function f3<T>(x: Partial<T>[keyof T], y: NonNullable<Partial<T>[keyof T]>) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
}
|
||||
|
||||
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 }
|
||||
type T11 = Filter<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type T12 = Diff<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
type T13 = Filter<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
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 }
|
||||
|
||||
type OptionsOfKind<K extends Options["k"]> = Filter<Options, { k: K }>;
|
||||
|
||||
type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Filter<T, { [P in K]: V }>;
|
||||
|
||||
type T17 = Select<Options, "k", "a" | "b">; // // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type TypeName<T> =
|
||||
T extends string ? "string" :
|
||||
T extends number ? "number" :
|
||||
T extends boolean ? "boolean" :
|
||||
T extends undefined ? "undefined" :
|
||||
T extends Function ? "function" :
|
||||
"object";
|
||||
|
||||
type T20 = TypeName<string | (() => void)>; // "string" | "function"
|
||||
type T21 = TypeName<any>; // "string" | "number" | "boolean" | "undefined" | "function" | "object"
|
||||
type T22 = TypeName<never>; // "string" | "number" | "boolean" | "undefined" | "function" | "object"
|
||||
type T23 = TypeName<{}>; // "object"
|
||||
|
||||
type KnockoutObservable<T> = { object: T };
|
||||
type KnockoutObservableArray<T> = { array: T };
|
||||
|
||||
type KnockedOut<T> = T extends any[] ? KnockoutObservableArray<T[number]> : KnockoutObservable<T>;
|
||||
|
||||
type KnockedOutObj<T> = {
|
||||
[P in keyof T]: KnockedOut<T[P]>;
|
||||
}
|
||||
|
||||
interface Item {
|
||||
id: number;
|
||||
name: string;
|
||||
subitems: string[];
|
||||
}
|
||||
|
||||
type KOItem = KnockedOutObj<Item>;
|
||||
|
||||
interface Part {
|
||||
id: number;
|
||||
name: string;
|
||||
subparts: Part[];
|
||||
updatePart(newName: string): void;
|
||||
}
|
||||
|
||||
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
|
||||
type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
|
||||
|
||||
type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T];
|
||||
type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
||||
|
||||
type T30 = FunctionProperties<Part>;
|
||||
type T31 = NonFunctionProperties<Part>;
|
||||
|
||||
function f7<T>(x: T, y: FunctionProperties<T>, z: NonFunctionProperties<T>) {
|
||||
x = y; // Error
|
||||
x = z; // Error
|
||||
y = x;
|
||||
y = z; // Error
|
||||
z = x;
|
||||
z = y; // Error
|
||||
}
|
||||
|
||||
function f8<T>(x: keyof T, y: FunctionPropertyNames<T>, z: NonFunctionPropertyNames<T>) {
|
||||
x = y;
|
||||
x = z;
|
||||
y = x; // Error
|
||||
y = z; // Error
|
||||
z = x; // Error
|
||||
z = y; // Error
|
||||
}
|
||||
|
||||
type DeepReadonly<T> =
|
||||
T extends any[] ? DeepReadonlyArray<T[number]> :
|
||||
T extends object ? DeepReadonlyObject<T> :
|
||||
T;
|
||||
|
||||
interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {}
|
||||
|
||||
type DeepReadonlyObject<T> = {
|
||||
readonly [P in NonFunctionPropertyNames<T>]: DeepReadonly<T[P]>;
|
||||
};
|
||||
|
||||
function f10(part: DeepReadonly<Part>) {
|
||||
let name: string = part.name;
|
||||
let id: number = part.subparts[0].id;
|
||||
part.id = part.id; // Error
|
||||
part.subparts[0] = part.subparts[0]; // Error
|
||||
part.subparts[0].id = part.subparts[0].id; // Error
|
||||
part.updatePart("hello"); // Error
|
||||
}
|
||||
|
||||
type ZeroOf<T extends number | string | boolean> = T extends number ? 0 : T extends string ? "" : false;
|
||||
|
||||
function zeroOf<T extends number | string | boolean>(value: T) {
|
||||
return <ZeroOf<T>>(typeof value === "number" ? 0 : typeof value === "string" ? "" : false);
|
||||
}
|
||||
|
||||
function f20<T extends string>(n: number, b: boolean, x: number | boolean, y: T) {
|
||||
zeroOf(5); // 0
|
||||
zeroOf("hello"); // ""
|
||||
zeroOf(true); // false
|
||||
zeroOf(n); // 0
|
||||
zeroOf(b); // False
|
||||
zeroOf(x); // 0 | false
|
||||
zeroOf(y); // ZeroOf<T>
|
||||
}
|
||||
|
||||
function f21<T extends number | string>(x: T, y: ZeroOf<T>) {
|
||||
let z1: number | string = y;
|
||||
let z2: 0 | "" = y;
|
||||
x = y; // Error
|
||||
y = x; // Error
|
||||
}
|
||||
|
||||
type Extends<T, U> = T extends U ? true : false;
|
||||
type If<C extends boolean, T, F> = C extends true ? T : F;
|
||||
type Not<C extends boolean> = If<C, false, true>;
|
||||
type And<A extends boolean, B extends boolean> = If<A, B, false>;
|
||||
type Or<A extends boolean, B extends boolean> = If<A, true, B>;
|
||||
|
||||
type isString<T> = Extends<T, string>;
|
||||
|
||||
type Q1 = isString<number>; // false
|
||||
type Q2 = isString<"abc">; // true
|
||||
type Q3 = isString<any>; // boolean
|
||||
type Q4 = isString<never>; // boolean
|
||||
|
||||
type N1 = Not<false>; // true
|
||||
type N2 = Not<true>; // false
|
||||
type N3 = Not<boolean>; // boolean
|
||||
|
||||
type A1 = And<false, false>; // false
|
||||
type A2 = And<false, true>; // false
|
||||
type A3 = And<true, false>; // false
|
||||
type A4 = And<true, true>; // true
|
||||
type A5 = And<boolean, false>; // false
|
||||
type A6 = And<false, boolean>; // false
|
||||
type A7 = And<boolean, true>; // boolean
|
||||
type A8 = And<true, boolean>; // boolean
|
||||
type A9 = And<boolean, boolean>; // boolean
|
||||
|
||||
type O1 = Or<false, false>; // false
|
||||
type O2 = Or<false, true>; // true
|
||||
type O3 = Or<true, false>; // true
|
||||
type O4 = Or<true, true>; // true
|
||||
type O5 = Or<boolean, false>; // boolean
|
||||
type O6 = Or<false, boolean>; // boolean
|
||||
type O7 = Or<boolean, true>; // true
|
||||
type O8 = Or<true, boolean>; // true
|
||||
type O9 = Or<boolean, boolean>; // boolean
|
||||
|
||||
|
||||
//// [conditionalTypes1.js]
|
||||
"use strict";
|
||||
function f1(x, y) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
}
|
||||
function f2(x, y) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
var s1 = x; // Error
|
||||
var s2 = y;
|
||||
}
|
||||
function f3(x, y) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
}
|
||||
var x0 = f4("a"); // { k: "a", a: number }
|
||||
function f7(x, y, z) {
|
||||
x = y; // Error
|
||||
x = z; // Error
|
||||
y = x;
|
||||
y = z; // Error
|
||||
z = x;
|
||||
z = y; // Error
|
||||
}
|
||||
function f8(x, y, z) {
|
||||
x = y;
|
||||
x = z;
|
||||
y = x; // Error
|
||||
y = z; // Error
|
||||
z = x; // Error
|
||||
z = y; // Error
|
||||
}
|
||||
function f10(part) {
|
||||
var name = part.name;
|
||||
var id = part.subparts[0].id;
|
||||
part.id = part.id; // Error
|
||||
part.subparts[0] = part.subparts[0]; // Error
|
||||
part.subparts[0].id = part.subparts[0].id; // Error
|
||||
part.updatePart("hello"); // Error
|
||||
}
|
||||
function zeroOf(value) {
|
||||
return (typeof value === "number" ? 0 : typeof value === "string" ? "" : false);
|
||||
}
|
||||
function f20(n, b, x, y) {
|
||||
zeroOf(5); // 0
|
||||
zeroOf("hello"); // ""
|
||||
zeroOf(true); // false
|
||||
zeroOf(n); // 0
|
||||
zeroOf(b); // False
|
||||
zeroOf(x); // 0 | false
|
||||
zeroOf(y); // ZeroOf<T>
|
||||
}
|
||||
function f21(x, y) {
|
||||
var z1 = y;
|
||||
var z2 = y;
|
||||
x = y; // Error
|
||||
y = x; // Error
|
||||
}
|
||||
|
||||
|
||||
//// [conditionalTypes1.d.ts]
|
||||
declare type Diff<T, U> = T extends U ? never : T;
|
||||
declare type Filter<T, U> = T extends U ? T : never;
|
||||
declare type NonNullable<T> = Diff<T, null | undefined>;
|
||||
declare type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">;
|
||||
declare type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">;
|
||||
declare type T02 = Diff<string | number | (() => void), Function>;
|
||||
declare type T03 = Filter<string | number | (() => void), Function>;
|
||||
declare type T04 = NonNullable<string | number | undefined>;
|
||||
declare type T05 = NonNullable<(() => string) | string[] | null | undefined>;
|
||||
declare function f1<T>(x: T, y: NonNullable<T>): void;
|
||||
declare function f2<T extends string | undefined>(x: T, y: NonNullable<T>): void;
|
||||
declare function f3<T>(x: Partial<T>[keyof T], y: NonNullable<Partial<T>[keyof T]>): void;
|
||||
declare type Options = {
|
||||
k: "a";
|
||||
a: number;
|
||||
} | {
|
||||
k: "b";
|
||||
b: string;
|
||||
} | {
|
||||
k: "c";
|
||||
c: boolean;
|
||||
};
|
||||
declare type T10 = Diff<Options, {
|
||||
k: "a" | "b";
|
||||
}>;
|
||||
declare type T11 = Filter<Options, {
|
||||
k: "a" | "b";
|
||||
}>;
|
||||
declare type T12 = Diff<Options, {
|
||||
k: "a";
|
||||
} | {
|
||||
k: "b";
|
||||
}>;
|
||||
declare type T13 = Filter<Options, {
|
||||
k: "a";
|
||||
} | {
|
||||
k: "b";
|
||||
}>;
|
||||
declare type T14 = Diff<Options, {
|
||||
q: "a";
|
||||
}>;
|
||||
declare type T15 = Filter<Options, {
|
||||
q: "a";
|
||||
}>;
|
||||
declare function f4<T extends Options, K extends string>(p: K): Filter<T, {
|
||||
k: K;
|
||||
}>;
|
||||
declare let x0: {
|
||||
k: "a";
|
||||
a: number;
|
||||
};
|
||||
declare type OptionsOfKind<K extends Options["k"]> = Filter<Options, {
|
||||
k: K;
|
||||
}>;
|
||||
declare type T16 = OptionsOfKind<"a" | "b">;
|
||||
declare type Select<T, K extends keyof T, V extends T[K]> = Filter<T, {
|
||||
[P in K]: V;
|
||||
}>;
|
||||
declare type T17 = Select<Options, "k", "a" | "b">;
|
||||
declare type TypeName<T> = T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends undefined ? "undefined" : T extends Function ? "function" : "object";
|
||||
declare type T20 = TypeName<string | (() => void)>;
|
||||
declare type T21 = TypeName<any>;
|
||||
declare type T22 = TypeName<never>;
|
||||
declare type T23 = TypeName<{}>;
|
||||
declare type KnockoutObservable<T> = {
|
||||
object: T;
|
||||
};
|
||||
declare type KnockoutObservableArray<T> = {
|
||||
array: T;
|
||||
};
|
||||
declare type KnockedOut<T> = T extends any[] ? KnockoutObservableArray<T[number]> : KnockoutObservable<T>;
|
||||
declare type KnockedOutObj<T> = {
|
||||
[P in keyof T]: KnockedOut<T[P]>;
|
||||
};
|
||||
interface Item {
|
||||
id: number;
|
||||
name: string;
|
||||
subitems: string[];
|
||||
}
|
||||
declare type KOItem = KnockedOutObj<Item>;
|
||||
interface Part {
|
||||
id: number;
|
||||
name: string;
|
||||
subparts: Part[];
|
||||
updatePart(newName: string): void;
|
||||
}
|
||||
declare type FunctionPropertyNames<T> = {
|
||||
[K in keyof T]: T[K] extends Function ? K : never;
|
||||
}[keyof T];
|
||||
declare type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
|
||||
declare type NonFunctionPropertyNames<T> = {
|
||||
[K in keyof T]: T[K] extends Function ? never : K;
|
||||
}[keyof T];
|
||||
declare type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
||||
declare type T30 = FunctionProperties<Part>;
|
||||
declare type T31 = NonFunctionProperties<Part>;
|
||||
declare function f7<T>(x: T, y: FunctionProperties<T>, z: NonFunctionProperties<T>): void;
|
||||
declare function f8<T>(x: keyof T, y: FunctionPropertyNames<T>, z: NonFunctionPropertyNames<T>): void;
|
||||
declare type DeepReadonly<T> = T extends any[] ? DeepReadonlyArray<T[number]> : T extends object ? DeepReadonlyObject<T> : T;
|
||||
interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {
|
||||
}
|
||||
declare type DeepReadonlyObject<T> = {
|
||||
readonly [P in NonFunctionPropertyNames<T>]: DeepReadonly<T[P]>;
|
||||
};
|
||||
declare function f10(part: DeepReadonly<Part>): void;
|
||||
declare type ZeroOf<T extends number | string | boolean> = T extends number ? 0 : T extends string ? "" : false;
|
||||
declare function zeroOf<T extends number | string | boolean>(value: T): ZeroOf<T>;
|
||||
declare function f20<T extends string>(n: number, b: boolean, x: number | boolean, y: T): void;
|
||||
declare function f21<T extends number | string>(x: T, y: ZeroOf<T>): void;
|
||||
declare type Extends<T, U> = T extends U ? true : false;
|
||||
declare type If<C extends boolean, T, F> = C extends true ? T : F;
|
||||
declare type Not<C extends boolean> = If<C, false, true>;
|
||||
declare type And<A extends boolean, B extends boolean> = If<A, B, false>;
|
||||
declare type Or<A extends boolean, B extends boolean> = If<A, true, B>;
|
||||
declare type isString<T> = Extends<T, string>;
|
||||
declare type Q1 = isString<number>;
|
||||
declare type Q2 = isString<"abc">;
|
||||
declare type Q3 = isString<any>;
|
||||
declare type Q4 = isString<never>;
|
||||
declare type N1 = Not<false>;
|
||||
declare type N2 = Not<true>;
|
||||
declare type N3 = Not<boolean>;
|
||||
declare type A1 = And<false, false>;
|
||||
declare type A2 = And<false, true>;
|
||||
declare type A3 = And<true, false>;
|
||||
declare type A4 = And<true, true>;
|
||||
declare type A5 = And<boolean, false>;
|
||||
declare type A6 = And<false, boolean>;
|
||||
declare type A7 = And<boolean, true>;
|
||||
declare type A8 = And<true, boolean>;
|
||||
declare type A9 = And<boolean, boolean>;
|
||||
declare type O1 = Or<false, false>;
|
||||
declare type O2 = Or<false, true>;
|
||||
declare type O3 = Or<true, false>;
|
||||
declare type O4 = Or<true, true>;
|
||||
declare type O5 = Or<boolean, false>;
|
||||
declare type O6 = Or<false, boolean>;
|
||||
declare type O7 = Or<boolean, true>;
|
||||
declare type O8 = Or<true, boolean>;
|
||||
declare type O9 = Or<boolean, boolean>;
|
||||
@@ -0,0 +1,753 @@
|
||||
=== tests/cases/conformance/types/conditional/conditionalTypes1.ts ===
|
||||
type Diff<T, U> = T extends U ? never : T;
|
||||
>Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 0, 10))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 0, 12))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 0, 10))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 0, 12))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 0, 10))
|
||||
|
||||
type Filter<T, U> = T extends U ? T : never;
|
||||
>Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 1, 12))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 1, 14))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 1, 12))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 1, 14))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 1, 12))
|
||||
|
||||
type NonNullable<T> = Diff<T, null | undefined>;
|
||||
>NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 2, 17))
|
||||
>Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 2, 17))
|
||||
|
||||
type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
>T00 : Symbol(T00, Decl(conditionalTypes1.ts, 2, 48))
|
||||
>Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0))
|
||||
|
||||
type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
>T01 : Symbol(T01, Decl(conditionalTypes1.ts, 4, 56))
|
||||
>Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42))
|
||||
|
||||
type T02 = Diff<string | number | (() => void), Function>; // string | number
|
||||
>T02 : Symbol(T02, Decl(conditionalTypes1.ts, 5, 58))
|
||||
>Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
type T03 = Filter<string | number | (() => void), Function>; // () => void
|
||||
>T03 : Symbol(T03, Decl(conditionalTypes1.ts, 7, 58))
|
||||
>Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
type T04 = NonNullable<string | number | undefined>; // string | number
|
||||
>T04 : Symbol(T04, Decl(conditionalTypes1.ts, 8, 60))
|
||||
>NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44))
|
||||
|
||||
type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[]
|
||||
>T05 : Symbol(T05, Decl(conditionalTypes1.ts, 10, 52))
|
||||
>NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44))
|
||||
|
||||
function f1<T>(x: T, y: NonNullable<T>) {
|
||||
>f1 : Symbol(f1, Decl(conditionalTypes1.ts, 11, 69))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 13, 12))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 13, 15))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 13, 12))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 13, 20))
|
||||
>NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 13, 12))
|
||||
|
||||
x = y;
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 13, 15))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 13, 20))
|
||||
|
||||
y = x; // Error
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 13, 20))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 13, 15))
|
||||
}
|
||||
|
||||
function f2<T extends string | undefined>(x: T, y: NonNullable<T>) {
|
||||
>f2 : Symbol(f2, Decl(conditionalTypes1.ts, 16, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 18, 12))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 18, 42))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 18, 12))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 18, 47))
|
||||
>NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 18, 12))
|
||||
|
||||
x = y;
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 18, 42))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 18, 47))
|
||||
|
||||
y = x; // Error
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 18, 47))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 18, 42))
|
||||
|
||||
let s1: string = x; // Error
|
||||
>s1 : Symbol(s1, Decl(conditionalTypes1.ts, 21, 7))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 18, 42))
|
||||
|
||||
let s2: string = y;
|
||||
>s2 : Symbol(s2, Decl(conditionalTypes1.ts, 22, 7))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 18, 47))
|
||||
}
|
||||
|
||||
function f3<T>(x: Partial<T>[keyof T], y: NonNullable<Partial<T>[keyof T]>) {
|
||||
>f3 : Symbol(f3, Decl(conditionalTypes1.ts, 23, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 25, 15))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 25, 38))
|
||||
>NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12))
|
||||
|
||||
x = y;
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 25, 15))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 25, 38))
|
||||
|
||||
y = x; // Error
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 25, 38))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 25, 15))
|
||||
}
|
||||
|
||||
type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean };
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 30, 16))
|
||||
>a : Symbol(a, Decl(conditionalTypes1.ts, 30, 24))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 30, 40))
|
||||
>b : Symbol(b, Decl(conditionalTypes1.ts, 30, 48))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 30, 64))
|
||||
>c : Symbol(c, Decl(conditionalTypes1.ts, 30, 72))
|
||||
|
||||
type T10 = Diff<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
>T10 : Symbol(T10, Decl(conditionalTypes1.ts, 30, 86))
|
||||
>Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 32, 26))
|
||||
|
||||
type T11 = Filter<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T11 : Symbol(T11, Decl(conditionalTypes1.ts, 32, 43))
|
||||
>Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 33, 28))
|
||||
|
||||
type T12 = Diff<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
>T12 : Symbol(T12, Decl(conditionalTypes1.ts, 33, 45))
|
||||
>Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 35, 26))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 35, 39))
|
||||
|
||||
type T13 = Filter<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T13 : Symbol(T13, Decl(conditionalTypes1.ts, 35, 50))
|
||||
>Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 36, 28))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 36, 41))
|
||||
|
||||
type T14 = Diff<Options, { q: "a" }>; // Options
|
||||
>T14 : Symbol(T14, Decl(conditionalTypes1.ts, 36, 52))
|
||||
>Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>q : Symbol(q, Decl(conditionalTypes1.ts, 38, 26))
|
||||
|
||||
type T15 = Filter<Options, { q: "a" }>; // never
|
||||
>T15 : Symbol(T15, Decl(conditionalTypes1.ts, 38, 37))
|
||||
>Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>q : Symbol(q, Decl(conditionalTypes1.ts, 39, 28))
|
||||
|
||||
declare function f4<T extends Options, K extends string>(p: K): Filter<T, { k: K }>;
|
||||
>f4 : Symbol(f4, Decl(conditionalTypes1.ts, 39, 39))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 41, 20))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 41, 38))
|
||||
>p : Symbol(p, Decl(conditionalTypes1.ts, 41, 57))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 41, 38))
|
||||
>Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 41, 20))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 41, 75))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 41, 38))
|
||||
|
||||
let x0 = f4("a"); // { k: "a", a: number }
|
||||
>x0 : Symbol(x0, Decl(conditionalTypes1.ts, 42, 3))
|
||||
>f4 : Symbol(f4, Decl(conditionalTypes1.ts, 39, 39))
|
||||
|
||||
type OptionsOfKind<K extends Options["k"]> = Filter<Options, { k: K }>;
|
||||
>OptionsOfKind : Symbol(OptionsOfKind, Decl(conditionalTypes1.ts, 42, 17))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 44, 19))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
>k : Symbol(k, Decl(conditionalTypes1.ts, 44, 62))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 44, 19))
|
||||
|
||||
type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T16 : Symbol(T16, Decl(conditionalTypes1.ts, 44, 71))
|
||||
>OptionsOfKind : Symbol(OptionsOfKind, Decl(conditionalTypes1.ts, 42, 17))
|
||||
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Filter<T, { [P in K]: V }>;
|
||||
>Select : Symbol(Select, Decl(conditionalTypes1.ts, 46, 36))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 48, 12))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 48, 14))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 48, 12))
|
||||
>V : Symbol(V, Decl(conditionalTypes1.ts, 48, 33))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 48, 12))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 48, 14))
|
||||
>Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 48, 12))
|
||||
>P : Symbol(P, Decl(conditionalTypes1.ts, 48, 65))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 48, 14))
|
||||
>V : Symbol(V, Decl(conditionalTypes1.ts, 48, 33))
|
||||
|
||||
type T17 = Select<Options, "k", "a" | "b">; // // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T17 : Symbol(T17, Decl(conditionalTypes1.ts, 48, 79))
|
||||
>Select : Symbol(Select, Decl(conditionalTypes1.ts, 46, 36))
|
||||
>Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1))
|
||||
|
||||
type TypeName<T> =
|
||||
>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14))
|
||||
|
||||
T extends string ? "string" :
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14))
|
||||
|
||||
T extends number ? "number" :
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14))
|
||||
|
||||
T extends boolean ? "boolean" :
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14))
|
||||
|
||||
T extends undefined ? "undefined" :
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14))
|
||||
|
||||
T extends Function ? "function" :
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
"object";
|
||||
|
||||
type T20 = TypeName<string | (() => void)>; // "string" | "function"
|
||||
>T20 : Symbol(T20, Decl(conditionalTypes1.ts, 58, 13))
|
||||
>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43))
|
||||
|
||||
type T21 = TypeName<any>; // "string" | "number" | "boolean" | "undefined" | "function" | "object"
|
||||
>T21 : Symbol(T21, Decl(conditionalTypes1.ts, 60, 43))
|
||||
>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43))
|
||||
|
||||
type T22 = TypeName<never>; // "string" | "number" | "boolean" | "undefined" | "function" | "object"
|
||||
>T22 : Symbol(T22, Decl(conditionalTypes1.ts, 61, 25))
|
||||
>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43))
|
||||
|
||||
type T23 = TypeName<{}>; // "object"
|
||||
>T23 : Symbol(T23, Decl(conditionalTypes1.ts, 62, 27))
|
||||
>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43))
|
||||
|
||||
type KnockoutObservable<T> = { object: T };
|
||||
>KnockoutObservable : Symbol(KnockoutObservable, Decl(conditionalTypes1.ts, 63, 24))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 65, 24))
|
||||
>object : Symbol(object, Decl(conditionalTypes1.ts, 65, 30))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 65, 24))
|
||||
|
||||
type KnockoutObservableArray<T> = { array: T };
|
||||
>KnockoutObservableArray : Symbol(KnockoutObservableArray, Decl(conditionalTypes1.ts, 65, 43))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 66, 29))
|
||||
>array : Symbol(array, Decl(conditionalTypes1.ts, 66, 35))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 66, 29))
|
||||
|
||||
type KnockedOut<T> = T extends any[] ? KnockoutObservableArray<T[number]> : KnockoutObservable<T>;
|
||||
>KnockedOut : Symbol(KnockedOut, Decl(conditionalTypes1.ts, 66, 47))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 68, 16))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 68, 16))
|
||||
>KnockoutObservableArray : Symbol(KnockoutObservableArray, Decl(conditionalTypes1.ts, 65, 43))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 68, 16))
|
||||
>KnockoutObservable : Symbol(KnockoutObservable, Decl(conditionalTypes1.ts, 63, 24))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 68, 16))
|
||||
|
||||
type KnockedOutObj<T> = {
|
||||
>KnockedOutObj : Symbol(KnockedOutObj, Decl(conditionalTypes1.ts, 68, 98))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 70, 19))
|
||||
|
||||
[P in keyof T]: KnockedOut<T[P]>;
|
||||
>P : Symbol(P, Decl(conditionalTypes1.ts, 71, 5))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 70, 19))
|
||||
>KnockedOut : Symbol(KnockedOut, Decl(conditionalTypes1.ts, 66, 47))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 70, 19))
|
||||
>P : Symbol(P, Decl(conditionalTypes1.ts, 71, 5))
|
||||
}
|
||||
|
||||
interface Item {
|
||||
>Item : Symbol(Item, Decl(conditionalTypes1.ts, 72, 1))
|
||||
|
||||
id: number;
|
||||
>id : Symbol(Item.id, Decl(conditionalTypes1.ts, 74, 16))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(Item.name, Decl(conditionalTypes1.ts, 75, 15))
|
||||
|
||||
subitems: string[];
|
||||
>subitems : Symbol(Item.subitems, Decl(conditionalTypes1.ts, 76, 17))
|
||||
}
|
||||
|
||||
type KOItem = KnockedOutObj<Item>;
|
||||
>KOItem : Symbol(KOItem, Decl(conditionalTypes1.ts, 78, 1))
|
||||
>KnockedOutObj : Symbol(KnockedOutObj, Decl(conditionalTypes1.ts, 68, 98))
|
||||
>Item : Symbol(Item, Decl(conditionalTypes1.ts, 72, 1))
|
||||
|
||||
interface Part {
|
||||
>Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34))
|
||||
|
||||
id: number;
|
||||
>id : Symbol(Part.id, Decl(conditionalTypes1.ts, 82, 16))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(Part.name, Decl(conditionalTypes1.ts, 83, 15))
|
||||
|
||||
subparts: Part[];
|
||||
>subparts : Symbol(Part.subparts, Decl(conditionalTypes1.ts, 84, 17))
|
||||
>Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34))
|
||||
|
||||
updatePart(newName: string): void;
|
||||
>updatePart : Symbol(Part.updatePart, Decl(conditionalTypes1.ts, 85, 21))
|
||||
>newName : Symbol(newName, Decl(conditionalTypes1.ts, 86, 15))
|
||||
}
|
||||
|
||||
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
|
||||
>FunctionPropertyNames : Symbol(FunctionPropertyNames, Decl(conditionalTypes1.ts, 87, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 89, 27))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 89, 35))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 89, 27))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 89, 27))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 89, 35))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 89, 35))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 89, 27))
|
||||
|
||||
type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
|
||||
>FunctionProperties : Symbol(FunctionProperties, Decl(conditionalTypes1.ts, 89, 95))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 90, 24))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 90, 24))
|
||||
>FunctionPropertyNames : Symbol(FunctionPropertyNames, Decl(conditionalTypes1.ts, 87, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 90, 24))
|
||||
|
||||
type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T];
|
||||
>NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 63))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 92, 30))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 92, 38))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 92, 30))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 92, 30))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 92, 38))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>K : Symbol(K, Decl(conditionalTypes1.ts, 92, 38))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 92, 30))
|
||||
|
||||
type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
||||
>NonFunctionProperties : Symbol(NonFunctionProperties, Decl(conditionalTypes1.ts, 92, 98))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 93, 27))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 93, 27))
|
||||
>NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 63))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 93, 27))
|
||||
|
||||
type T30 = FunctionProperties<Part>;
|
||||
>T30 : Symbol(T30, Decl(conditionalTypes1.ts, 93, 69))
|
||||
>FunctionProperties : Symbol(FunctionProperties, Decl(conditionalTypes1.ts, 89, 95))
|
||||
>Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34))
|
||||
|
||||
type T31 = NonFunctionProperties<Part>;
|
||||
>T31 : Symbol(T31, Decl(conditionalTypes1.ts, 95, 36))
|
||||
>NonFunctionProperties : Symbol(NonFunctionProperties, Decl(conditionalTypes1.ts, 92, 98))
|
||||
>Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34))
|
||||
|
||||
function f7<T>(x: T, y: FunctionProperties<T>, z: NonFunctionProperties<T>) {
|
||||
>f7 : Symbol(f7, Decl(conditionalTypes1.ts, 96, 39))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 98, 12))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 98, 12))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20))
|
||||
>FunctionProperties : Symbol(FunctionProperties, Decl(conditionalTypes1.ts, 89, 95))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 98, 12))
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46))
|
||||
>NonFunctionProperties : Symbol(NonFunctionProperties, Decl(conditionalTypes1.ts, 92, 98))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 98, 12))
|
||||
|
||||
x = y; // Error
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20))
|
||||
|
||||
x = z; // Error
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15))
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46))
|
||||
|
||||
y = x;
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15))
|
||||
|
||||
y = z; // Error
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20))
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46))
|
||||
|
||||
z = x;
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15))
|
||||
|
||||
z = y; // Error
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20))
|
||||
}
|
||||
|
||||
function f8<T>(x: keyof T, y: FunctionPropertyNames<T>, z: NonFunctionPropertyNames<T>) {
|
||||
>f8 : Symbol(f8, Decl(conditionalTypes1.ts, 105, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 107, 12))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 107, 12))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26))
|
||||
>FunctionPropertyNames : Symbol(FunctionPropertyNames, Decl(conditionalTypes1.ts, 87, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 107, 12))
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55))
|
||||
>NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 63))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 107, 12))
|
||||
|
||||
x = y;
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26))
|
||||
|
||||
x = z;
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15))
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55))
|
||||
|
||||
y = x; // Error
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15))
|
||||
|
||||
y = z; // Error
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26))
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55))
|
||||
|
||||
z = x; // Error
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15))
|
||||
|
||||
z = y; // Error
|
||||
>z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26))
|
||||
}
|
||||
|
||||
type DeepReadonly<T> =
|
||||
>DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 114, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18))
|
||||
|
||||
T extends any[] ? DeepReadonlyArray<T[number]> :
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18))
|
||||
>DeepReadonlyArray : Symbol(DeepReadonlyArray, Decl(conditionalTypes1.ts, 119, 6))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18))
|
||||
|
||||
T extends object ? DeepReadonlyObject<T> :
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18))
|
||||
>DeepReadonlyObject : Symbol(DeepReadonlyObject, Decl(conditionalTypes1.ts, 121, 72))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18))
|
||||
|
||||
T;
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18))
|
||||
|
||||
interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {}
|
||||
>DeepReadonlyArray : Symbol(DeepReadonlyArray, Decl(conditionalTypes1.ts, 119, 6))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 121, 28))
|
||||
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.d.ts, --, --))
|
||||
>DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 114, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 121, 28))
|
||||
|
||||
type DeepReadonlyObject<T> = {
|
||||
>DeepReadonlyObject : Symbol(DeepReadonlyObject, Decl(conditionalTypes1.ts, 121, 72))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 123, 24))
|
||||
|
||||
readonly [P in NonFunctionPropertyNames<T>]: DeepReadonly<T[P]>;
|
||||
>P : Symbol(P, Decl(conditionalTypes1.ts, 124, 14))
|
||||
>NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 63))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 123, 24))
|
||||
>DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 114, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 123, 24))
|
||||
>P : Symbol(P, Decl(conditionalTypes1.ts, 124, 14))
|
||||
|
||||
};
|
||||
|
||||
function f10(part: DeepReadonly<Part>) {
|
||||
>f10 : Symbol(f10, Decl(conditionalTypes1.ts, 125, 2))
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
>DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 114, 1))
|
||||
>Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34))
|
||||
|
||||
let name: string = part.name;
|
||||
>name : Symbol(name, Decl(conditionalTypes1.ts, 128, 7))
|
||||
>part.name : Symbol(name)
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
>name : Symbol(name)
|
||||
|
||||
let id: number = part.subparts[0].id;
|
||||
>id : Symbol(id, Decl(conditionalTypes1.ts, 129, 7))
|
||||
>part.subparts[0].id : Symbol(id)
|
||||
>part.subparts : Symbol(subparts)
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
>subparts : Symbol(subparts)
|
||||
>id : Symbol(id)
|
||||
|
||||
part.id = part.id; // Error
|
||||
>part.id : Symbol(id)
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
>id : Symbol(id)
|
||||
>part.id : Symbol(id)
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
>id : Symbol(id)
|
||||
|
||||
part.subparts[0] = part.subparts[0]; // Error
|
||||
>part.subparts : Symbol(subparts)
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
>subparts : Symbol(subparts)
|
||||
>part.subparts : Symbol(subparts)
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
>subparts : Symbol(subparts)
|
||||
|
||||
part.subparts[0].id = part.subparts[0].id; // Error
|
||||
>part.subparts[0].id : Symbol(id)
|
||||
>part.subparts : Symbol(subparts)
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
>subparts : Symbol(subparts)
|
||||
>id : Symbol(id)
|
||||
>part.subparts[0].id : Symbol(id)
|
||||
>part.subparts : Symbol(subparts)
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
>subparts : Symbol(subparts)
|
||||
>id : Symbol(id)
|
||||
|
||||
part.updatePart("hello"); // Error
|
||||
>part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13))
|
||||
}
|
||||
|
||||
type ZeroOf<T extends number | string | boolean> = T extends number ? 0 : T extends string ? "" : false;
|
||||
>ZeroOf : Symbol(ZeroOf, Decl(conditionalTypes1.ts, 134, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 136, 12))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 136, 12))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 136, 12))
|
||||
|
||||
function zeroOf<T extends number | string | boolean>(value: T) {
|
||||
>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 138, 16))
|
||||
>value : Symbol(value, Decl(conditionalTypes1.ts, 138, 53))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 138, 16))
|
||||
|
||||
return <ZeroOf<T>>(typeof value === "number" ? 0 : typeof value === "string" ? "" : false);
|
||||
>ZeroOf : Symbol(ZeroOf, Decl(conditionalTypes1.ts, 134, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 138, 16))
|
||||
>value : Symbol(value, Decl(conditionalTypes1.ts, 138, 53))
|
||||
>value : Symbol(value, Decl(conditionalTypes1.ts, 138, 53))
|
||||
}
|
||||
|
||||
function f20<T extends string>(n: number, b: boolean, x: number | boolean, y: T) {
|
||||
>f20 : Symbol(f20, Decl(conditionalTypes1.ts, 140, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 142, 13))
|
||||
>n : Symbol(n, Decl(conditionalTypes1.ts, 142, 31))
|
||||
>b : Symbol(b, Decl(conditionalTypes1.ts, 142, 41))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 142, 53))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 142, 74))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 142, 13))
|
||||
|
||||
zeroOf(5); // 0
|
||||
>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104))
|
||||
|
||||
zeroOf("hello"); // ""
|
||||
>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104))
|
||||
|
||||
zeroOf(true); // false
|
||||
>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104))
|
||||
|
||||
zeroOf(n); // 0
|
||||
>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104))
|
||||
>n : Symbol(n, Decl(conditionalTypes1.ts, 142, 31))
|
||||
|
||||
zeroOf(b); // False
|
||||
>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104))
|
||||
>b : Symbol(b, Decl(conditionalTypes1.ts, 142, 41))
|
||||
|
||||
zeroOf(x); // 0 | false
|
||||
>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 142, 53))
|
||||
|
||||
zeroOf(y); // ZeroOf<T>
|
||||
>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 142, 74))
|
||||
}
|
||||
|
||||
function f21<T extends number | string>(x: T, y: ZeroOf<T>) {
|
||||
>f21 : Symbol(f21, Decl(conditionalTypes1.ts, 150, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 152, 13))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 152, 40))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 152, 13))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45))
|
||||
>ZeroOf : Symbol(ZeroOf, Decl(conditionalTypes1.ts, 134, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 152, 13))
|
||||
|
||||
let z1: number | string = y;
|
||||
>z1 : Symbol(z1, Decl(conditionalTypes1.ts, 153, 7))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45))
|
||||
|
||||
let z2: 0 | "" = y;
|
||||
>z2 : Symbol(z2, Decl(conditionalTypes1.ts, 154, 7))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45))
|
||||
|
||||
x = y; // Error
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 152, 40))
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45))
|
||||
|
||||
y = x; // Error
|
||||
>y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45))
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 152, 40))
|
||||
}
|
||||
|
||||
type Extends<T, U> = T extends U ? true : false;
|
||||
>Extends : Symbol(Extends, Decl(conditionalTypes1.ts, 157, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 159, 13))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 159, 15))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 159, 13))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 159, 15))
|
||||
|
||||
type If<C extends boolean, T, F> = C extends true ? T : F;
|
||||
>If : Symbol(If, Decl(conditionalTypes1.ts, 159, 48))
|
||||
>C : Symbol(C, Decl(conditionalTypes1.ts, 160, 8))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 160, 26))
|
||||
>F : Symbol(F, Decl(conditionalTypes1.ts, 160, 29))
|
||||
>C : Symbol(C, Decl(conditionalTypes1.ts, 160, 8))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 160, 26))
|
||||
>F : Symbol(F, Decl(conditionalTypes1.ts, 160, 29))
|
||||
|
||||
type Not<C extends boolean> = If<C, false, true>;
|
||||
>Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58))
|
||||
>C : Symbol(C, Decl(conditionalTypes1.ts, 161, 9))
|
||||
>If : Symbol(If, Decl(conditionalTypes1.ts, 159, 48))
|
||||
>C : Symbol(C, Decl(conditionalTypes1.ts, 161, 9))
|
||||
|
||||
type And<A extends boolean, B extends boolean> = If<A, B, false>;
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
>A : Symbol(A, Decl(conditionalTypes1.ts, 162, 9))
|
||||
>B : Symbol(B, Decl(conditionalTypes1.ts, 162, 27))
|
||||
>If : Symbol(If, Decl(conditionalTypes1.ts, 159, 48))
|
||||
>A : Symbol(A, Decl(conditionalTypes1.ts, 162, 9))
|
||||
>B : Symbol(B, Decl(conditionalTypes1.ts, 162, 27))
|
||||
|
||||
type Or<A extends boolean, B extends boolean> = If<A, true, B>;
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
>A : Symbol(A, Decl(conditionalTypes1.ts, 163, 8))
|
||||
>B : Symbol(B, Decl(conditionalTypes1.ts, 163, 26))
|
||||
>If : Symbol(If, Decl(conditionalTypes1.ts, 159, 48))
|
||||
>A : Symbol(A, Decl(conditionalTypes1.ts, 163, 8))
|
||||
>B : Symbol(B, Decl(conditionalTypes1.ts, 163, 26))
|
||||
|
||||
type isString<T> = Extends<T, string>;
|
||||
>isString : Symbol(isString, Decl(conditionalTypes1.ts, 163, 63))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 165, 14))
|
||||
>Extends : Symbol(Extends, Decl(conditionalTypes1.ts, 157, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 165, 14))
|
||||
|
||||
type Q1 = isString<number>; // false
|
||||
>Q1 : Symbol(Q1, Decl(conditionalTypes1.ts, 165, 38))
|
||||
>isString : Symbol(isString, Decl(conditionalTypes1.ts, 163, 63))
|
||||
|
||||
type Q2 = isString<"abc">; // true
|
||||
>Q2 : Symbol(Q2, Decl(conditionalTypes1.ts, 167, 27))
|
||||
>isString : Symbol(isString, Decl(conditionalTypes1.ts, 163, 63))
|
||||
|
||||
type Q3 = isString<any>; // boolean
|
||||
>Q3 : Symbol(Q3, Decl(conditionalTypes1.ts, 168, 26))
|
||||
>isString : Symbol(isString, Decl(conditionalTypes1.ts, 163, 63))
|
||||
|
||||
type Q4 = isString<never>; // boolean
|
||||
>Q4 : Symbol(Q4, Decl(conditionalTypes1.ts, 169, 24))
|
||||
>isString : Symbol(isString, Decl(conditionalTypes1.ts, 163, 63))
|
||||
|
||||
type N1 = Not<false>; // true
|
||||
>N1 : Symbol(N1, Decl(conditionalTypes1.ts, 170, 26))
|
||||
>Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58))
|
||||
|
||||
type N2 = Not<true>; // false
|
||||
>N2 : Symbol(N2, Decl(conditionalTypes1.ts, 172, 21))
|
||||
>Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58))
|
||||
|
||||
type N3 = Not<boolean>; // boolean
|
||||
>N3 : Symbol(N3, Decl(conditionalTypes1.ts, 173, 20))
|
||||
>Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58))
|
||||
|
||||
type A1 = And<false, false>; // false
|
||||
>A1 : Symbol(A1, Decl(conditionalTypes1.ts, 174, 23))
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
|
||||
type A2 = And<false, true>; // false
|
||||
>A2 : Symbol(A2, Decl(conditionalTypes1.ts, 176, 28))
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
|
||||
type A3 = And<true, false>; // false
|
||||
>A3 : Symbol(A3, Decl(conditionalTypes1.ts, 177, 27))
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
|
||||
type A4 = And<true, true>; // true
|
||||
>A4 : Symbol(A4, Decl(conditionalTypes1.ts, 178, 27))
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
|
||||
type A5 = And<boolean, false>; // false
|
||||
>A5 : Symbol(A5, Decl(conditionalTypes1.ts, 179, 26))
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
|
||||
type A6 = And<false, boolean>; // false
|
||||
>A6 : Symbol(A6, Decl(conditionalTypes1.ts, 180, 30))
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
|
||||
type A7 = And<boolean, true>; // boolean
|
||||
>A7 : Symbol(A7, Decl(conditionalTypes1.ts, 181, 30))
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
|
||||
type A8 = And<true, boolean>; // boolean
|
||||
>A8 : Symbol(A8, Decl(conditionalTypes1.ts, 182, 29))
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
|
||||
type A9 = And<boolean, boolean>; // boolean
|
||||
>A9 : Symbol(A9, Decl(conditionalTypes1.ts, 183, 29))
|
||||
>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49))
|
||||
|
||||
type O1 = Or<false, false>; // false
|
||||
>O1 : Symbol(O1, Decl(conditionalTypes1.ts, 184, 32))
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
|
||||
type O2 = Or<false, true>; // true
|
||||
>O2 : Symbol(O2, Decl(conditionalTypes1.ts, 186, 27))
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
|
||||
type O3 = Or<true, false>; // true
|
||||
>O3 : Symbol(O3, Decl(conditionalTypes1.ts, 187, 26))
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
|
||||
type O4 = Or<true, true>; // true
|
||||
>O4 : Symbol(O4, Decl(conditionalTypes1.ts, 188, 26))
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
|
||||
type O5 = Or<boolean, false>; // boolean
|
||||
>O5 : Symbol(O5, Decl(conditionalTypes1.ts, 189, 25))
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
|
||||
type O6 = Or<false, boolean>; // boolean
|
||||
>O6 : Symbol(O6, Decl(conditionalTypes1.ts, 190, 29))
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
|
||||
type O7 = Or<boolean, true>; // true
|
||||
>O7 : Symbol(O7, Decl(conditionalTypes1.ts, 191, 29))
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
|
||||
type O8 = Or<true, boolean>; // true
|
||||
>O8 : Symbol(O8, Decl(conditionalTypes1.ts, 192, 28))
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
|
||||
type O9 = Or<boolean, boolean>; // boolean
|
||||
>O9 : Symbol(O9, Decl(conditionalTypes1.ts, 193, 28))
|
||||
>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65))
|
||||
|
||||
@@ -0,0 +1,851 @@
|
||||
=== tests/cases/conformance/types/conditional/conditionalTypes1.ts ===
|
||||
type Diff<T, U> = T extends U ? never : T;
|
||||
>Diff : Diff<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
|
||||
type Filter<T, U> = T extends U ? T : never;
|
||||
>Filter : Filter<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
|
||||
type NonNullable<T> = Diff<T, null | undefined>;
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>T : T
|
||||
>Diff : Diff<T, U>
|
||||
>T : T
|
||||
>null : null
|
||||
|
||||
type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
>T00 : "b" | "d"
|
||||
>Diff : Diff<T, U>
|
||||
|
||||
type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
>T01 : "a" | "c"
|
||||
>Filter : Filter<T, U>
|
||||
|
||||
type T02 = Diff<string | number | (() => void), Function>; // string | number
|
||||
>T02 : string | number
|
||||
>Diff : Diff<T, U>
|
||||
>Function : Function
|
||||
|
||||
type T03 = Filter<string | number | (() => void), Function>; // () => void
|
||||
>T03 : () => void
|
||||
>Filter : Filter<T, U>
|
||||
>Function : Function
|
||||
|
||||
type T04 = NonNullable<string | number | undefined>; // string | number
|
||||
>T04 : string | number
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
|
||||
type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[]
|
||||
>T05 : (() => string) | string[]
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>null : null
|
||||
|
||||
function f1<T>(x: T, y: NonNullable<T>) {
|
||||
>f1 : <T>(x: T, y: Diff<T, null | undefined>) => void
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>T : T
|
||||
|
||||
x = y;
|
||||
>x = y : Diff<T, null | undefined>
|
||||
>x : T
|
||||
>y : Diff<T, null | undefined>
|
||||
|
||||
y = x; // Error
|
||||
>y = x : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>x : T
|
||||
}
|
||||
|
||||
function f2<T extends string | undefined>(x: T, y: NonNullable<T>) {
|
||||
>f2 : <T extends string | undefined>(x: T, y: Diff<T, null | undefined>) => void
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>T : T
|
||||
|
||||
x = y;
|
||||
>x = y : Diff<T, null | undefined>
|
||||
>x : T
|
||||
>y : Diff<T, null | undefined>
|
||||
|
||||
y = x; // Error
|
||||
>y = x : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>x : T
|
||||
|
||||
let s1: string = x; // Error
|
||||
>s1 : string
|
||||
>x : T
|
||||
|
||||
let s2: string = y;
|
||||
>s2 : string
|
||||
>y : Diff<T, null | undefined>
|
||||
}
|
||||
|
||||
function f3<T>(x: Partial<T>[keyof T], y: NonNullable<Partial<T>[keyof T]>) {
|
||||
>f3 : <T>(x: Partial<T>[keyof T], y: Diff<Partial<T>[keyof T], null | undefined>) => void
|
||||
>T : T
|
||||
>x : Partial<T>[keyof T]
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
>T : T
|
||||
>y : Diff<Partial<T>[keyof T], null | undefined>
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
x = y;
|
||||
>x = y : Diff<Partial<T>[keyof T], null | undefined>
|
||||
>x : Partial<T>[keyof T]
|
||||
>y : Diff<Partial<T>[keyof T], null | undefined>
|
||||
|
||||
y = x; // Error
|
||||
>y = x : Partial<T>[keyof T]
|
||||
>y : Diff<Partial<T>[keyof T], null | undefined>
|
||||
>x : Partial<T>[keyof T]
|
||||
}
|
||||
|
||||
type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean };
|
||||
>Options : Options
|
||||
>k : "a"
|
||||
>a : number
|
||||
>k : "b"
|
||||
>b : string
|
||||
>k : "c"
|
||||
>c : boolean
|
||||
|
||||
type T10 = Diff<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
>T10 : { k: "c"; c: boolean; }
|
||||
>Diff : Diff<T, U>
|
||||
>Options : Options
|
||||
>k : "a" | "b"
|
||||
|
||||
type T11 = Filter<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T11 : { k: "a"; a: number; } | { k: "b"; b: string; }
|
||||
>Filter : Filter<T, U>
|
||||
>Options : Options
|
||||
>k : "a" | "b"
|
||||
|
||||
type T12 = Diff<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
>T12 : { k: "c"; c: boolean; }
|
||||
>Diff : Diff<T, U>
|
||||
>Options : Options
|
||||
>k : "a"
|
||||
>k : "b"
|
||||
|
||||
type T13 = Filter<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T13 : { k: "a"; a: number; } | { k: "b"; b: string; }
|
||||
>Filter : Filter<T, U>
|
||||
>Options : Options
|
||||
>k : "a"
|
||||
>k : "b"
|
||||
|
||||
type T14 = Diff<Options, { q: "a" }>; // Options
|
||||
>T14 : Options
|
||||
>Diff : Diff<T, U>
|
||||
>Options : Options
|
||||
>q : "a"
|
||||
|
||||
type T15 = Filter<Options, { q: "a" }>; // never
|
||||
>T15 : never
|
||||
>Filter : Filter<T, U>
|
||||
>Options : Options
|
||||
>q : "a"
|
||||
|
||||
declare function f4<T extends Options, K extends string>(p: K): Filter<T, { k: K }>;
|
||||
>f4 : <T extends Options, K extends string>(p: K) => Filter<T, { k: K; }>
|
||||
>T : T
|
||||
>Options : Options
|
||||
>K : K
|
||||
>p : K
|
||||
>K : K
|
||||
>Filter : Filter<T, U>
|
||||
>T : T
|
||||
>k : K
|
||||
>K : K
|
||||
|
||||
let x0 = f4("a"); // { k: "a", a: number }
|
||||
>x0 : { k: "a"; a: number; }
|
||||
>f4("a") : { k: "a"; a: number; }
|
||||
>f4 : <T extends Options, K extends string>(p: K) => Filter<T, { k: K; }>
|
||||
>"a" : "a"
|
||||
|
||||
type OptionsOfKind<K extends Options["k"]> = Filter<Options, { k: K }>;
|
||||
>OptionsOfKind : Filter<{ k: "a"; a: number; }, { k: K; }> | Filter<{ k: "b"; b: string; }, { k: K; }> | Filter<{ k: "c"; c: boolean; }, { k: K; }>
|
||||
>K : K
|
||||
>Options : Options
|
||||
>Filter : Filter<T, U>
|
||||
>Options : Options
|
||||
>k : K
|
||||
>K : K
|
||||
|
||||
type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T16 : { k: "a"; a: number; } | { k: "b"; b: string; }
|
||||
>OptionsOfKind : Filter<{ k: "a"; a: number; }, { k: K; }> | Filter<{ k: "b"; b: string; }, { k: K; }> | Filter<{ k: "c"; c: boolean; }, { k: K; }>
|
||||
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Filter<T, { [P in K]: V }>;
|
||||
>Select : Filter<T, { [P in K]: V; }>
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>V : V
|
||||
>T : T
|
||||
>K : K
|
||||
>Filter : Filter<T, U>
|
||||
>T : T
|
||||
>P : P
|
||||
>K : K
|
||||
>V : V
|
||||
|
||||
type T17 = Select<Options, "k", "a" | "b">; // // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T17 : { k: "a"; a: number; } | { k: "b"; b: string; }
|
||||
>Select : Filter<T, { [P in K]: V; }>
|
||||
>Options : Options
|
||||
|
||||
type TypeName<T> =
|
||||
>TypeName : TypeName<T>
|
||||
>T : T
|
||||
|
||||
T extends string ? "string" :
|
||||
>T : T
|
||||
|
||||
T extends number ? "number" :
|
||||
>T : T
|
||||
|
||||
T extends boolean ? "boolean" :
|
||||
>T : T
|
||||
|
||||
T extends undefined ? "undefined" :
|
||||
>T : T
|
||||
|
||||
T extends Function ? "function" :
|
||||
>T : T
|
||||
>Function : Function
|
||||
|
||||
"object";
|
||||
|
||||
type T20 = TypeName<string | (() => void)>; // "string" | "function"
|
||||
>T20 : "string" | "function"
|
||||
>TypeName : TypeName<T>
|
||||
|
||||
type T21 = TypeName<any>; // "string" | "number" | "boolean" | "undefined" | "function" | "object"
|
||||
>T21 : "string" | "number" | "boolean" | "undefined" | "object" | "function"
|
||||
>TypeName : TypeName<T>
|
||||
|
||||
type T22 = TypeName<never>; // "string" | "number" | "boolean" | "undefined" | "function" | "object"
|
||||
>T22 : "string" | "number" | "boolean" | "undefined" | "object" | "function"
|
||||
>TypeName : TypeName<T>
|
||||
|
||||
type T23 = TypeName<{}>; // "object"
|
||||
>T23 : "object"
|
||||
>TypeName : TypeName<T>
|
||||
|
||||
type KnockoutObservable<T> = { object: T };
|
||||
>KnockoutObservable : KnockoutObservable<T>
|
||||
>T : T
|
||||
>object : T
|
||||
>T : T
|
||||
|
||||
type KnockoutObservableArray<T> = { array: T };
|
||||
>KnockoutObservableArray : KnockoutObservableArray<T>
|
||||
>T : T
|
||||
>array : T
|
||||
>T : T
|
||||
|
||||
type KnockedOut<T> = T extends any[] ? KnockoutObservableArray<T[number]> : KnockoutObservable<T>;
|
||||
>KnockedOut : KnockedOut<T>
|
||||
>T : T
|
||||
>T : T
|
||||
>KnockoutObservableArray : KnockoutObservableArray<T>
|
||||
>T : T
|
||||
>KnockoutObservable : KnockoutObservable<T>
|
||||
>T : T
|
||||
|
||||
type KnockedOutObj<T> = {
|
||||
>KnockedOutObj : KnockedOutObj<T>
|
||||
>T : T
|
||||
|
||||
[P in keyof T]: KnockedOut<T[P]>;
|
||||
>P : P
|
||||
>T : T
|
||||
>KnockedOut : KnockedOut<T>
|
||||
>T : T
|
||||
>P : P
|
||||
}
|
||||
|
||||
interface Item {
|
||||
>Item : Item
|
||||
|
||||
id: number;
|
||||
>id : number
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
|
||||
subitems: string[];
|
||||
>subitems : string[]
|
||||
}
|
||||
|
||||
type KOItem = KnockedOutObj<Item>;
|
||||
>KOItem : KnockedOutObj<Item>
|
||||
>KnockedOutObj : KnockedOutObj<T>
|
||||
>Item : Item
|
||||
|
||||
interface Part {
|
||||
>Part : Part
|
||||
|
||||
id: number;
|
||||
>id : number
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
|
||||
subparts: Part[];
|
||||
>subparts : Part[]
|
||||
>Part : Part
|
||||
|
||||
updatePart(newName: string): void;
|
||||
>updatePart : (newName: string) => void
|
||||
>newName : string
|
||||
}
|
||||
|
||||
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
|
||||
>FunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>T : T
|
||||
>K : K
|
||||
>Function : Function
|
||||
>K : K
|
||||
>T : T
|
||||
|
||||
type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
|
||||
>FunctionProperties : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
>T : T
|
||||
>Pick : Pick<T, K>
|
||||
>T : T
|
||||
>FunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
>T : T
|
||||
|
||||
type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T];
|
||||
>NonFunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>T : T
|
||||
>K : K
|
||||
>Function : Function
|
||||
>K : K
|
||||
>T : T
|
||||
|
||||
type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
||||
>NonFunctionProperties : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
>T : T
|
||||
>Pick : Pick<T, K>
|
||||
>T : T
|
||||
>NonFunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
>T : T
|
||||
|
||||
type T30 = FunctionProperties<Part>;
|
||||
>T30 : Pick<Part, "updatePart">
|
||||
>FunctionProperties : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
>Part : Part
|
||||
|
||||
type T31 = NonFunctionProperties<Part>;
|
||||
>T31 : Pick<Part, "id" | "name" | "subparts">
|
||||
>NonFunctionProperties : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
>Part : Part
|
||||
|
||||
function f7<T>(x: T, y: FunctionProperties<T>, z: NonFunctionProperties<T>) {
|
||||
>f7 : <T>(x: T, y: Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>, z: Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>) => void
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>y : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
>FunctionProperties : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
>T : T
|
||||
>z : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
>NonFunctionProperties : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
>T : T
|
||||
|
||||
x = y; // Error
|
||||
>x = y : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
>x : T
|
||||
>y : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
|
||||
x = z; // Error
|
||||
>x = z : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
>x : T
|
||||
>z : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
|
||||
y = x;
|
||||
>y = x : T
|
||||
>y : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
>x : T
|
||||
|
||||
y = z; // Error
|
||||
>y = z : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
>y : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
>z : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
|
||||
z = x;
|
||||
>z = x : T
|
||||
>z : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
>x : T
|
||||
|
||||
z = y; // Error
|
||||
>z = y : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
>z : Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>
|
||||
>y : Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>
|
||||
}
|
||||
|
||||
function f8<T>(x: keyof T, y: FunctionPropertyNames<T>, z: NonFunctionPropertyNames<T>) {
|
||||
>f8 : <T>(x: keyof T, y: { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T], z: { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]) => void
|
||||
>T : T
|
||||
>x : keyof T
|
||||
>T : T
|
||||
>y : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
>FunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
>T : T
|
||||
>z : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
>NonFunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
>T : T
|
||||
|
||||
x = y;
|
||||
>x = y : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
>x : keyof T
|
||||
>y : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
|
||||
x = z;
|
||||
>x = z : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
>x : keyof T
|
||||
>z : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
|
||||
y = x; // Error
|
||||
>y = x : keyof T
|
||||
>y : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
>x : keyof T
|
||||
|
||||
y = z; // Error
|
||||
>y = z : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
>y : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
>z : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
|
||||
z = x; // Error
|
||||
>z = x : keyof T
|
||||
>z : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
>x : keyof T
|
||||
|
||||
z = y; // Error
|
||||
>z = y : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
>z : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
>y : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]
|
||||
}
|
||||
|
||||
type DeepReadonly<T> =
|
||||
>DeepReadonly : DeepReadonly<T>
|
||||
>T : T
|
||||
|
||||
T extends any[] ? DeepReadonlyArray<T[number]> :
|
||||
>T : T
|
||||
>DeepReadonlyArray : DeepReadonlyArray<T>
|
||||
>T : T
|
||||
|
||||
T extends object ? DeepReadonlyObject<T> :
|
||||
>T : T
|
||||
>DeepReadonlyObject : DeepReadonlyObject<T>
|
||||
>T : T
|
||||
|
||||
T;
|
||||
>T : T
|
||||
|
||||
interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {}
|
||||
>DeepReadonlyArray : DeepReadonlyArray<T>
|
||||
>T : T
|
||||
>ReadonlyArray : ReadonlyArray<T>
|
||||
>DeepReadonly : DeepReadonly<T>
|
||||
>T : T
|
||||
|
||||
type DeepReadonlyObject<T> = {
|
||||
>DeepReadonlyObject : DeepReadonlyObject<T>
|
||||
>T : T
|
||||
|
||||
readonly [P in NonFunctionPropertyNames<T>]: DeepReadonly<T[P]>;
|
||||
>P : P
|
||||
>NonFunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]
|
||||
>T : T
|
||||
>DeepReadonly : DeepReadonly<T>
|
||||
>T : T
|
||||
>P : P
|
||||
|
||||
};
|
||||
|
||||
function f10(part: DeepReadonly<Part>) {
|
||||
>f10 : (part: DeepReadonlyObject<Part>) => void
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>DeepReadonly : DeepReadonly<T>
|
||||
>Part : Part
|
||||
|
||||
let name: string = part.name;
|
||||
>name : string
|
||||
>part.name : string
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>name : string
|
||||
|
||||
let id: number = part.subparts[0].id;
|
||||
>id : number
|
||||
>part.subparts[0].id : number
|
||||
>part.subparts[0] : DeepReadonlyObject<Part>
|
||||
>part.subparts : DeepReadonlyArray<Part>
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>subparts : DeepReadonlyArray<Part>
|
||||
>0 : 0
|
||||
>id : number
|
||||
|
||||
part.id = part.id; // Error
|
||||
>part.id = part.id : number
|
||||
>part.id : any
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>id : any
|
||||
>part.id : number
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>id : number
|
||||
|
||||
part.subparts[0] = part.subparts[0]; // Error
|
||||
>part.subparts[0] = part.subparts[0] : DeepReadonlyObject<Part>
|
||||
>part.subparts[0] : DeepReadonlyObject<Part>
|
||||
>part.subparts : DeepReadonlyArray<Part>
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>subparts : DeepReadonlyArray<Part>
|
||||
>0 : 0
|
||||
>part.subparts[0] : DeepReadonlyObject<Part>
|
||||
>part.subparts : DeepReadonlyArray<Part>
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>subparts : DeepReadonlyArray<Part>
|
||||
>0 : 0
|
||||
|
||||
part.subparts[0].id = part.subparts[0].id; // Error
|
||||
>part.subparts[0].id = part.subparts[0].id : number
|
||||
>part.subparts[0].id : any
|
||||
>part.subparts[0] : DeepReadonlyObject<Part>
|
||||
>part.subparts : DeepReadonlyArray<Part>
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>subparts : DeepReadonlyArray<Part>
|
||||
>0 : 0
|
||||
>id : any
|
||||
>part.subparts[0].id : number
|
||||
>part.subparts[0] : DeepReadonlyObject<Part>
|
||||
>part.subparts : DeepReadonlyArray<Part>
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>subparts : DeepReadonlyArray<Part>
|
||||
>0 : 0
|
||||
>id : number
|
||||
|
||||
part.updatePart("hello"); // Error
|
||||
>part.updatePart("hello") : any
|
||||
>part.updatePart : any
|
||||
>part : DeepReadonlyObject<Part>
|
||||
>updatePart : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
|
||||
type ZeroOf<T extends number | string | boolean> = T extends number ? 0 : T extends string ? "" : false;
|
||||
>ZeroOf : ZeroOf<T>
|
||||
>T : T
|
||||
>T : T
|
||||
>T : T
|
||||
>false : false
|
||||
|
||||
function zeroOf<T extends number | string | boolean>(value: T) {
|
||||
>zeroOf : <T extends string | number | boolean>(value: T) => ZeroOf<T>
|
||||
>T : T
|
||||
>value : T
|
||||
>T : T
|
||||
|
||||
return <ZeroOf<T>>(typeof value === "number" ? 0 : typeof value === "string" ? "" : false);
|
||||
><ZeroOf<T>>(typeof value === "number" ? 0 : typeof value === "string" ? "" : false) : ZeroOf<T>
|
||||
>ZeroOf : ZeroOf<T>
|
||||
>T : T
|
||||
>(typeof value === "number" ? 0 : typeof value === "string" ? "" : false) : false | 0 | ""
|
||||
>typeof value === "number" ? 0 : typeof value === "string" ? "" : false : false | 0 | ""
|
||||
>typeof value === "number" : boolean
|
||||
>typeof value : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>value : T
|
||||
>"number" : "number"
|
||||
>0 : 0
|
||||
>typeof value === "string" ? "" : false : false | ""
|
||||
>typeof value === "string" : boolean
|
||||
>typeof value : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>value : T
|
||||
>"string" : "string"
|
||||
>"" : ""
|
||||
>false : false
|
||||
}
|
||||
|
||||
function f20<T extends string>(n: number, b: boolean, x: number | boolean, y: T) {
|
||||
>f20 : <T extends string>(n: number, b: boolean, x: number | boolean, y: T) => void
|
||||
>T : T
|
||||
>n : number
|
||||
>b : boolean
|
||||
>x : number | boolean
|
||||
>y : T
|
||||
>T : T
|
||||
|
||||
zeroOf(5); // 0
|
||||
>zeroOf(5) : 0
|
||||
>zeroOf : <T extends string | number | boolean>(value: T) => ZeroOf<T>
|
||||
>5 : 5
|
||||
|
||||
zeroOf("hello"); // ""
|
||||
>zeroOf("hello") : ""
|
||||
>zeroOf : <T extends string | number | boolean>(value: T) => ZeroOf<T>
|
||||
>"hello" : "hello"
|
||||
|
||||
zeroOf(true); // false
|
||||
>zeroOf(true) : false
|
||||
>zeroOf : <T extends string | number | boolean>(value: T) => ZeroOf<T>
|
||||
>true : true
|
||||
|
||||
zeroOf(n); // 0
|
||||
>zeroOf(n) : 0
|
||||
>zeroOf : <T extends string | number | boolean>(value: T) => ZeroOf<T>
|
||||
>n : number
|
||||
|
||||
zeroOf(b); // False
|
||||
>zeroOf(b) : false
|
||||
>zeroOf : <T extends string | number | boolean>(value: T) => ZeroOf<T>
|
||||
>b : boolean
|
||||
|
||||
zeroOf(x); // 0 | false
|
||||
>zeroOf(x) : false | 0
|
||||
>zeroOf : <T extends string | number | boolean>(value: T) => ZeroOf<T>
|
||||
>x : number | boolean
|
||||
|
||||
zeroOf(y); // ZeroOf<T>
|
||||
>zeroOf(y) : ZeroOf<T>
|
||||
>zeroOf : <T extends string | number | boolean>(value: T) => ZeroOf<T>
|
||||
>y : T
|
||||
}
|
||||
|
||||
function f21<T extends number | string>(x: T, y: ZeroOf<T>) {
|
||||
>f21 : <T extends string | number>(x: T, y: ZeroOf<T>) => void
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>y : ZeroOf<T>
|
||||
>ZeroOf : ZeroOf<T>
|
||||
>T : T
|
||||
|
||||
let z1: number | string = y;
|
||||
>z1 : string | number
|
||||
>y : ZeroOf<T>
|
||||
|
||||
let z2: 0 | "" = y;
|
||||
>z2 : "" | 0
|
||||
>y : ZeroOf<T>
|
||||
|
||||
x = y; // Error
|
||||
>x = y : ZeroOf<T>
|
||||
>x : T
|
||||
>y : ZeroOf<T>
|
||||
|
||||
y = x; // Error
|
||||
>y = x : T
|
||||
>y : ZeroOf<T>
|
||||
>x : T
|
||||
}
|
||||
|
||||
type Extends<T, U> = T extends U ? true : false;
|
||||
>Extends : Extends<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
>U : U
|
||||
>true : true
|
||||
>false : false
|
||||
|
||||
type If<C extends boolean, T, F> = C extends true ? T : F;
|
||||
>If : If<C, T, F>
|
||||
>C : C
|
||||
>T : T
|
||||
>F : F
|
||||
>C : C
|
||||
>true : true
|
||||
>T : T
|
||||
>F : F
|
||||
|
||||
type Not<C extends boolean> = If<C, false, true>;
|
||||
>Not : If<C, false, true>
|
||||
>C : C
|
||||
>If : If<C, T, F>
|
||||
>C : C
|
||||
>false : false
|
||||
>true : true
|
||||
|
||||
type And<A extends boolean, B extends boolean> = If<A, B, false>;
|
||||
>And : If<A, B, false>
|
||||
>A : A
|
||||
>B : B
|
||||
>If : If<C, T, F>
|
||||
>A : A
|
||||
>B : B
|
||||
>false : false
|
||||
|
||||
type Or<A extends boolean, B extends boolean> = If<A, true, B>;
|
||||
>Or : If<A, true, B>
|
||||
>A : A
|
||||
>B : B
|
||||
>If : If<C, T, F>
|
||||
>A : A
|
||||
>true : true
|
||||
>B : B
|
||||
|
||||
type isString<T> = Extends<T, string>;
|
||||
>isString : Extends<T, string>
|
||||
>T : T
|
||||
>Extends : Extends<T, U>
|
||||
>T : T
|
||||
|
||||
type Q1 = isString<number>; // false
|
||||
>Q1 : false
|
||||
>isString : Extends<T, string>
|
||||
|
||||
type Q2 = isString<"abc">; // true
|
||||
>Q2 : true
|
||||
>isString : Extends<T, string>
|
||||
|
||||
type Q3 = isString<any>; // boolean
|
||||
>Q3 : boolean
|
||||
>isString : Extends<T, string>
|
||||
|
||||
type Q4 = isString<never>; // boolean
|
||||
>Q4 : boolean
|
||||
>isString : Extends<T, string>
|
||||
|
||||
type N1 = Not<false>; // true
|
||||
>N1 : true
|
||||
>Not : If<C, false, true>
|
||||
>false : false
|
||||
|
||||
type N2 = Not<true>; // false
|
||||
>N2 : false
|
||||
>Not : If<C, false, true>
|
||||
>true : true
|
||||
|
||||
type N3 = Not<boolean>; // boolean
|
||||
>N3 : boolean
|
||||
>Not : If<C, false, true>
|
||||
|
||||
type A1 = And<false, false>; // false
|
||||
>A1 : false
|
||||
>And : If<A, B, false>
|
||||
>false : false
|
||||
>false : false
|
||||
|
||||
type A2 = And<false, true>; // false
|
||||
>A2 : false
|
||||
>And : If<A, B, false>
|
||||
>false : false
|
||||
>true : true
|
||||
|
||||
type A3 = And<true, false>; // false
|
||||
>A3 : false
|
||||
>And : If<A, B, false>
|
||||
>true : true
|
||||
>false : false
|
||||
|
||||
type A4 = And<true, true>; // true
|
||||
>A4 : true
|
||||
>And : If<A, B, false>
|
||||
>true : true
|
||||
>true : true
|
||||
|
||||
type A5 = And<boolean, false>; // false
|
||||
>A5 : false
|
||||
>And : If<A, B, false>
|
||||
>false : false
|
||||
|
||||
type A6 = And<false, boolean>; // false
|
||||
>A6 : false
|
||||
>And : If<A, B, false>
|
||||
>false : false
|
||||
|
||||
type A7 = And<boolean, true>; // boolean
|
||||
>A7 : boolean
|
||||
>And : If<A, B, false>
|
||||
>true : true
|
||||
|
||||
type A8 = And<true, boolean>; // boolean
|
||||
>A8 : boolean
|
||||
>And : If<A, B, false>
|
||||
>true : true
|
||||
|
||||
type A9 = And<boolean, boolean>; // boolean
|
||||
>A9 : boolean
|
||||
>And : If<A, B, false>
|
||||
|
||||
type O1 = Or<false, false>; // false
|
||||
>O1 : false
|
||||
>Or : If<A, true, B>
|
||||
>false : false
|
||||
>false : false
|
||||
|
||||
type O2 = Or<false, true>; // true
|
||||
>O2 : true
|
||||
>Or : If<A, true, B>
|
||||
>false : false
|
||||
>true : true
|
||||
|
||||
type O3 = Or<true, false>; // true
|
||||
>O3 : true
|
||||
>Or : If<A, true, B>
|
||||
>true : true
|
||||
>false : false
|
||||
|
||||
type O4 = Or<true, true>; // true
|
||||
>O4 : true
|
||||
>Or : If<A, true, B>
|
||||
>true : true
|
||||
>true : true
|
||||
|
||||
type O5 = Or<boolean, false>; // boolean
|
||||
>O5 : boolean
|
||||
>Or : If<A, true, B>
|
||||
>false : false
|
||||
|
||||
type O6 = Or<false, boolean>; // boolean
|
||||
>O6 : boolean
|
||||
>Or : If<A, true, B>
|
||||
>false : false
|
||||
|
||||
type O7 = Or<boolean, true>; // true
|
||||
>O7 : true
|
||||
>Or : If<A, true, B>
|
||||
>true : true
|
||||
|
||||
type O8 = Or<true, boolean>; // true
|
||||
>O8 : true
|
||||
>Or : If<A, true, B>
|
||||
>true : true
|
||||
|
||||
type O9 = Or<boolean, boolean>; // boolean
|
||||
>O9 : boolean
|
||||
>Or : If<A, true, B>
|
||||
|
||||
Reference in new issue
Block a user