diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt new file mode 100644 index 00000000000..900925052ac --- /dev/null +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -0,0 +1,337 @@ +tests/cases/conformance/types/conditional/conditionalTypes1.ts(16,5): error TS2322: Type 'T' is not assignable to type 'Diff'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(21,5): error TS2322: Type 'T' is not assignable to type 'Diff'. + Type 'string | undefined' is not assignable to type 'Diff'. + Type 'undefined' is not assignable to type 'Diff'. +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[keyof T]' is not assignable to type 'Diff[keyof T], null | undefined>'. + Type 'T[keyof T] | undefined' is not assignable to type 'Diff[keyof T], null | undefined>'. + Type 'undefined' is not assignable to type 'Diff[keyof T], null | undefined>'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(100,5): error TS2322: Type 'Pick' is not assignable to type 'T'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(101,5): error TS2322: Type 'Pick' is not assignable to type 'T'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. + 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' is not assignable to type 'Pick'. + 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' 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'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(156,5): error TS2322: Type 'ZeroOf' 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'. + Type 'string | number' is not assignable to type 'ZeroOf'. + Type 'string' is not assignable to type 'ZeroOf'. + + +==== tests/cases/conformance/types/conditional/conditionalTypes1.ts (18 errors) ==== + type Diff = T extends U ? never : T; + type Filter = T extends U ? T : never; + type NonNullable = Diff; + + 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 void), Function>; // string | number + type T03 = Filter void), Function>; // () => void + + type T04 = NonNullable; // string | number + type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] + + function f1(x: T, y: NonNullable) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type 'T' is not assignable to type 'Diff'. + } + + function f2(x: T, y: NonNullable) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type 'T' is not assignable to type 'Diff'. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'Diff'. +!!! error TS2322: Type 'undefined' is not assignable to type 'Diff'. + 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(x: Partial[keyof T], y: NonNullable[keyof T]>) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type 'Partial[keyof T]' is not assignable to type 'Diff[keyof T], null | undefined>'. +!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'Diff[keyof T], null | undefined>'. +!!! error TS2322: Type 'undefined' is not assignable to type 'Diff[keyof T], null | undefined>'. + } + + type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean }; + + type T10 = Diff; // { k: "c", c: boolean } + type T11 = Filter; // { k: "a", a: number } | { k: "b", b: string } + + type T12 = Diff; // { k: "c", c: boolean } + type T13 = Filter; // { k: "a", a: number } | { k: "b", b: string } + + type T14 = Diff; // Options + type T15 = Filter; // never + + declare function f4(p: K): Filter; + let x0 = f4("a"); // { k: "a", a: number } + + type OptionsOfKind = Filter; + + type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string } + + type Select = Filter; + + type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } + + type TypeName = + T extends string ? "string" : + T extends number ? "number" : + T extends boolean ? "boolean" : + T extends undefined ? "undefined" : + T extends Function ? "function" : + "object"; + + type T20 = TypeName void)>; // "string" | "function" + type T21 = TypeName; // "string" | "number" | "boolean" | "undefined" | "function" | "object" + type T22 = TypeName; // "string" | "number" | "boolean" | "undefined" | "function" | "object" + type T23 = TypeName<{}>; // "object" + + type KnockoutObservable = { object: T }; + type KnockoutObservableArray = { array: T }; + + type KnockedOut = T extends any[] ? KnockoutObservableArray : KnockoutObservable; + + type KnockedOutObj = { + [P in keyof T]: KnockedOut; + } + + interface Item { + id: number; + name: string; + subitems: string[]; + } + + type KOItem = KnockedOutObj; + + interface Part { + id: number; + name: string; + subparts: Part[]; + updatePart(newName: string): void; + } + + type FunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T]; + type FunctionProperties = Pick>; + + type NonFunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T]; + type NonFunctionProperties = Pick>; + + type T30 = FunctionProperties; + type T31 = NonFunctionProperties; + + function f7(x: T, y: FunctionProperties, z: NonFunctionProperties) { + x = y; // Error + ~ +!!! error TS2322: Type 'Pick' is not assignable to type 'T'. + x = z; // Error + ~ +!!! error TS2322: Type 'Pick' is not assignable to type 'T'. + y = x; + y = z; // Error + ~ +!!! error TS2322: Type 'Pick' is not assignable to type 'Pick'. +!!! 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' is not assignable to type 'Pick'. +!!! 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(x: keyof T, y: FunctionPropertyNames, z: NonFunctionPropertyNames) { + 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 extends any[] ? DeepReadonlyArray : + T extends object ? DeepReadonlyObject : + T; + + interface DeepReadonlyArray extends ReadonlyArray> {} + + type DeepReadonlyObject = { + readonly [P in NonFunctionPropertyNames]: DeepReadonly; + }; + + function f10(part: DeepReadonly) { + 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' 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'. + } + + type ZeroOf = T extends number ? 0 : T extends string ? "" : false; + + function zeroOf(value: T) { + return >(typeof value === "number" ? 0 : typeof value === "string" ? "" : false); + } + + function f20(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 + } + + function f21(x: T, y: ZeroOf) { + let z1: number | string = y; + let z2: 0 | "" = y; + x = y; // Error + ~ +!!! error TS2322: Type 'ZeroOf' 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'. +!!! error TS2322: Type 'string | number' is not assignable to type 'ZeroOf'. +!!! error TS2322: Type 'string' is not assignable to type 'ZeroOf'. + } + + type Extends = T extends U ? true : false; + type If = C extends true ? T : F; + type Not = If; + type And = If; + type Or = If; + + type isString = Extends; + + type Q1 = isString; // false + type Q2 = isString<"abc">; // true + type Q3 = isString; // boolean + type Q4 = isString; // boolean + + type N1 = Not; // true + type N2 = Not; // false + type N3 = Not; // boolean + + type A1 = And; // false + type A2 = And; // false + type A3 = And; // false + type A4 = And; // true + type A5 = And; // false + type A6 = And; // false + type A7 = And; // boolean + type A8 = And; // boolean + type A9 = And; // boolean + + type O1 = Or; // false + type O2 = Or; // true + type O3 = Or; // true + type O4 = Or; // true + type O5 = Or; // boolean + type O6 = Or; // boolean + type O7 = Or; // true + type O8 = Or; // true + type O9 = Or; // boolean + \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypes1.js b/tests/baselines/reference/conditionalTypes1.js new file mode 100644 index 00000000000..54241bb553a --- /dev/null +++ b/tests/baselines/reference/conditionalTypes1.js @@ -0,0 +1,400 @@ +//// [conditionalTypes1.ts] +type Diff = T extends U ? never : T; +type Filter = T extends U ? T : never; +type NonNullable = Diff; + +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 void), Function>; // string | number +type T03 = Filter void), Function>; // () => void + +type T04 = NonNullable; // string | number +type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] + +function f1(x: T, y: NonNullable) { + x = y; + y = x; // Error +} + +function f2(x: T, y: NonNullable) { + x = y; + y = x; // Error + let s1: string = x; // Error + let s2: string = y; +} + +function f3(x: Partial[keyof T], y: NonNullable[keyof T]>) { + x = y; + y = x; // Error +} + +type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean }; + +type T10 = Diff; // { k: "c", c: boolean } +type T11 = Filter; // { k: "a", a: number } | { k: "b", b: string } + +type T12 = Diff; // { k: "c", c: boolean } +type T13 = Filter; // { k: "a", a: number } | { k: "b", b: string } + +type T14 = Diff; // Options +type T15 = Filter; // never + +declare function f4(p: K): Filter; +let x0 = f4("a"); // { k: "a", a: number } + +type OptionsOfKind = Filter; + +type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string } + +type Select = Filter; + +type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } + +type TypeName = + T extends string ? "string" : + T extends number ? "number" : + T extends boolean ? "boolean" : + T extends undefined ? "undefined" : + T extends Function ? "function" : + "object"; + +type T20 = TypeName void)>; // "string" | "function" +type T21 = TypeName; // "string" | "number" | "boolean" | "undefined" | "function" | "object" +type T22 = TypeName; // "string" | "number" | "boolean" | "undefined" | "function" | "object" +type T23 = TypeName<{}>; // "object" + +type KnockoutObservable = { object: T }; +type KnockoutObservableArray = { array: T }; + +type KnockedOut = T extends any[] ? KnockoutObservableArray : KnockoutObservable; + +type KnockedOutObj = { + [P in keyof T]: KnockedOut; +} + +interface Item { + id: number; + name: string; + subitems: string[]; +} + +type KOItem = KnockedOutObj; + +interface Part { + id: number; + name: string; + subparts: Part[]; + updatePart(newName: string): void; +} + +type FunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T]; +type FunctionProperties = Pick>; + +type NonFunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T]; +type NonFunctionProperties = Pick>; + +type T30 = FunctionProperties; +type T31 = NonFunctionProperties; + +function f7(x: T, y: FunctionProperties, z: NonFunctionProperties) { + x = y; // Error + x = z; // Error + y = x; + y = z; // Error + z = x; + z = y; // Error +} + +function f8(x: keyof T, y: FunctionPropertyNames, z: NonFunctionPropertyNames) { + x = y; + x = z; + y = x; // Error + y = z; // Error + z = x; // Error + z = y; // Error +} + +type DeepReadonly = + T extends any[] ? DeepReadonlyArray : + T extends object ? DeepReadonlyObject : + T; + +interface DeepReadonlyArray extends ReadonlyArray> {} + +type DeepReadonlyObject = { + readonly [P in NonFunctionPropertyNames]: DeepReadonly; +}; + +function f10(part: DeepReadonly) { + 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 ? 0 : T extends string ? "" : false; + +function zeroOf(value: T) { + return >(typeof value === "number" ? 0 : typeof value === "string" ? "" : false); +} + +function f20(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 +} + +function f21(x: T, y: ZeroOf) { + let z1: number | string = y; + let z2: 0 | "" = y; + x = y; // Error + y = x; // Error +} + +type Extends = T extends U ? true : false; +type If = C extends true ? T : F; +type Not = If; +type And = If; +type Or = If; + +type isString = Extends; + +type Q1 = isString; // false +type Q2 = isString<"abc">; // true +type Q3 = isString; // boolean +type Q4 = isString; // boolean + +type N1 = Not; // true +type N2 = Not; // false +type N3 = Not; // boolean + +type A1 = And; // false +type A2 = And; // false +type A3 = And; // false +type A4 = And; // true +type A5 = And; // false +type A6 = And; // false +type A7 = And; // boolean +type A8 = And; // boolean +type A9 = And; // boolean + +type O1 = Or; // false +type O2 = Or; // true +type O3 = Or; // true +type O4 = Or; // true +type O5 = Or; // boolean +type O6 = Or; // boolean +type O7 = Or; // true +type O8 = Or; // true +type O9 = Or; // 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 +} +function f21(x, y) { + var z1 = y; + var z2 = y; + x = y; // Error + y = x; // Error +} + + +//// [conditionalTypes1.d.ts] +declare type Diff = T extends U ? never : T; +declare type Filter = T extends U ? T : never; +declare type NonNullable = Diff; +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 void), Function>; +declare type T03 = Filter void), Function>; +declare type T04 = NonNullable; +declare type T05 = NonNullable<(() => string) | string[] | null | undefined>; +declare function f1(x: T, y: NonNullable): void; +declare function f2(x: T, y: NonNullable): void; +declare function f3(x: Partial[keyof T], y: NonNullable[keyof T]>): void; +declare type Options = { + k: "a"; + a: number; +} | { + k: "b"; + b: string; +} | { + k: "c"; + c: boolean; +}; +declare type T10 = Diff; +declare type T11 = Filter; +declare type T12 = Diff; +declare type T13 = Filter; +declare type T14 = Diff; +declare type T15 = Filter; +declare function f4(p: K): Filter; +declare let x0: { + k: "a"; + a: number; +}; +declare type OptionsOfKind = Filter; +declare type T16 = OptionsOfKind<"a" | "b">; +declare type Select = Filter; +declare type T17 = Select; +declare type TypeName = 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 void)>; +declare type T21 = TypeName; +declare type T22 = TypeName; +declare type T23 = TypeName<{}>; +declare type KnockoutObservable = { + object: T; +}; +declare type KnockoutObservableArray = { + array: T; +}; +declare type KnockedOut = T extends any[] ? KnockoutObservableArray : KnockoutObservable; +declare type KnockedOutObj = { + [P in keyof T]: KnockedOut; +}; +interface Item { + id: number; + name: string; + subitems: string[]; +} +declare type KOItem = KnockedOutObj; +interface Part { + id: number; + name: string; + subparts: Part[]; + updatePart(newName: string): void; +} +declare type FunctionPropertyNames = { + [K in keyof T]: T[K] extends Function ? K : never; +}[keyof T]; +declare type FunctionProperties = Pick>; +declare type NonFunctionPropertyNames = { + [K in keyof T]: T[K] extends Function ? never : K; +}[keyof T]; +declare type NonFunctionProperties = Pick>; +declare type T30 = FunctionProperties; +declare type T31 = NonFunctionProperties; +declare function f7(x: T, y: FunctionProperties, z: NonFunctionProperties): void; +declare function f8(x: keyof T, y: FunctionPropertyNames, z: NonFunctionPropertyNames): void; +declare type DeepReadonly = T extends any[] ? DeepReadonlyArray : T extends object ? DeepReadonlyObject : T; +interface DeepReadonlyArray extends ReadonlyArray> { +} +declare type DeepReadonlyObject = { + readonly [P in NonFunctionPropertyNames]: DeepReadonly; +}; +declare function f10(part: DeepReadonly): void; +declare type ZeroOf = T extends number ? 0 : T extends string ? "" : false; +declare function zeroOf(value: T): ZeroOf; +declare function f20(n: number, b: boolean, x: number | boolean, y: T): void; +declare function f21(x: T, y: ZeroOf): void; +declare type Extends = T extends U ? true : false; +declare type If = C extends true ? T : F; +declare type Not = If; +declare type And = If; +declare type Or = If; +declare type isString = Extends; +declare type Q1 = isString; +declare type Q2 = isString<"abc">; +declare type Q3 = isString; +declare type Q4 = isString; +declare type N1 = Not; +declare type N2 = Not; +declare type N3 = Not; +declare type A1 = And; +declare type A2 = And; +declare type A3 = And; +declare type A4 = And; +declare type A5 = And; +declare type A6 = And; +declare type A7 = And; +declare type A8 = And; +declare type A9 = And; +declare type O1 = Or; +declare type O2 = Or; +declare type O3 = Or; +declare type O4 = Or; +declare type O5 = Or; +declare type O6 = Or; +declare type O7 = Or; +declare type O8 = Or; +declare type O9 = Or; diff --git a/tests/baselines/reference/conditionalTypes1.symbols b/tests/baselines/reference/conditionalTypes1.symbols new file mode 100644 index 00000000000..16322f4c151 --- /dev/null +++ b/tests/baselines/reference/conditionalTypes1.symbols @@ -0,0 +1,753 @@ +=== tests/cases/conformance/types/conditional/conditionalTypes1.ts === +type Diff = 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 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 = Diff; +>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 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 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 +>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(x: T, y: NonNullable) { +>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(x: T, y: NonNullable) { +>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(x: Partial[keyof T], y: NonNullable[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; // { 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; // { 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; // { 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; // { 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 +>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; // 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(p: K): Filter; +>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 = Filter; +>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 = Filter; +>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; // // { 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 = +>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 void)>; // "string" | "function" +>T20 : Symbol(T20, Decl(conditionalTypes1.ts, 58, 13)) +>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43)) + +type T21 = TypeName; // "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; // "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 = { 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 = { 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 extends any[] ? KnockoutObservableArray : KnockoutObservable; +>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 = { +>KnockedOutObj : Symbol(KnockedOutObj, Decl(conditionalTypes1.ts, 68, 98)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 70, 19)) + + [P in keyof T]: KnockedOut; +>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; +>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 = { [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 = Pick>; +>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 = { [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 = Pick>; +>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; +>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; +>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(x: T, y: FunctionProperties, z: NonFunctionProperties) { +>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(x: keyof T, y: FunctionPropertyNames, z: NonFunctionPropertyNames) { +>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 = +>DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 114, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18)) + + T extends any[] ? DeepReadonlyArray : +>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 : 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 extends ReadonlyArray> {} +>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 = { +>DeepReadonlyObject : Symbol(DeepReadonlyObject, Decl(conditionalTypes1.ts, 121, 72)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 123, 24)) + + readonly [P in NonFunctionPropertyNames]: DeepReadonly; +>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) { +>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 ? 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(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 >(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(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 +>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 142, 74)) +} + +function f21(x: T, y: ZeroOf) { +>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 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 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 = If; +>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 = If; +>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 = If; +>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 = Extends; +>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; // 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; // boolean +>Q3 : Symbol(Q3, Decl(conditionalTypes1.ts, 168, 26)) +>isString : Symbol(isString, Decl(conditionalTypes1.ts, 163, 63)) + +type Q4 = isString; // boolean +>Q4 : Symbol(Q4, Decl(conditionalTypes1.ts, 169, 24)) +>isString : Symbol(isString, Decl(conditionalTypes1.ts, 163, 63)) + +type N1 = Not; // true +>N1 : Symbol(N1, Decl(conditionalTypes1.ts, 170, 26)) +>Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58)) + +type N2 = Not; // false +>N2 : Symbol(N2, Decl(conditionalTypes1.ts, 172, 21)) +>Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58)) + +type N3 = Not; // boolean +>N3 : Symbol(N3, Decl(conditionalTypes1.ts, 173, 20)) +>Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58)) + +type A1 = And; // false +>A1 : Symbol(A1, Decl(conditionalTypes1.ts, 174, 23)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) + +type A2 = And; // false +>A2 : Symbol(A2, Decl(conditionalTypes1.ts, 176, 28)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) + +type A3 = And; // false +>A3 : Symbol(A3, Decl(conditionalTypes1.ts, 177, 27)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) + +type A4 = And; // true +>A4 : Symbol(A4, Decl(conditionalTypes1.ts, 178, 27)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) + +type A5 = And; // false +>A5 : Symbol(A5, Decl(conditionalTypes1.ts, 179, 26)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) + +type A6 = And; // false +>A6 : Symbol(A6, Decl(conditionalTypes1.ts, 180, 30)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) + +type A7 = And; // boolean +>A7 : Symbol(A7, Decl(conditionalTypes1.ts, 181, 30)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) + +type A8 = And; // boolean +>A8 : Symbol(A8, Decl(conditionalTypes1.ts, 182, 29)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) + +type A9 = And; // boolean +>A9 : Symbol(A9, Decl(conditionalTypes1.ts, 183, 29)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) + +type O1 = Or; // false +>O1 : Symbol(O1, Decl(conditionalTypes1.ts, 184, 32)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) + +type O2 = Or; // true +>O2 : Symbol(O2, Decl(conditionalTypes1.ts, 186, 27)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) + +type O3 = Or; // true +>O3 : Symbol(O3, Decl(conditionalTypes1.ts, 187, 26)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) + +type O4 = Or; // true +>O4 : Symbol(O4, Decl(conditionalTypes1.ts, 188, 26)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) + +type O5 = Or; // boolean +>O5 : Symbol(O5, Decl(conditionalTypes1.ts, 189, 25)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) + +type O6 = Or; // boolean +>O6 : Symbol(O6, Decl(conditionalTypes1.ts, 190, 29)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) + +type O7 = Or; // true +>O7 : Symbol(O7, Decl(conditionalTypes1.ts, 191, 29)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) + +type O8 = Or; // true +>O8 : Symbol(O8, Decl(conditionalTypes1.ts, 192, 28)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) + +type O9 = Or; // boolean +>O9 : Symbol(O9, Decl(conditionalTypes1.ts, 193, 28)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) + diff --git a/tests/baselines/reference/conditionalTypes1.types b/tests/baselines/reference/conditionalTypes1.types new file mode 100644 index 00000000000..86a02fa001b --- /dev/null +++ b/tests/baselines/reference/conditionalTypes1.types @@ -0,0 +1,851 @@ +=== tests/cases/conformance/types/conditional/conditionalTypes1.ts === +type Diff = T extends U ? never : T; +>Diff : Diff +>T : T +>U : U +>T : T +>U : U +>T : T + +type Filter = T extends U ? T : never; +>Filter : Filter +>T : T +>U : U +>T : T +>U : U +>T : T + +type NonNullable = Diff; +>NonNullable : Diff +>T : T +>Diff : Diff +>T : T +>null : null + +type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" +>T00 : "b" | "d" +>Diff : Diff + +type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" +>T01 : "a" | "c" +>Filter : Filter + +type T02 = Diff void), Function>; // string | number +>T02 : string | number +>Diff : Diff +>Function : Function + +type T03 = Filter void), Function>; // () => void +>T03 : () => void +>Filter : Filter +>Function : Function + +type T04 = NonNullable; // string | number +>T04 : string | number +>NonNullable : Diff + +type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] +>T05 : (() => string) | string[] +>NonNullable : Diff +>null : null + +function f1(x: T, y: NonNullable) { +>f1 : (x: T, y: Diff) => void +>T : T +>x : T +>T : T +>y : Diff +>NonNullable : Diff +>T : T + + x = y; +>x = y : Diff +>x : T +>y : Diff + + y = x; // Error +>y = x : T +>y : Diff +>x : T +} + +function f2(x: T, y: NonNullable) { +>f2 : (x: T, y: Diff) => void +>T : T +>x : T +>T : T +>y : Diff +>NonNullable : Diff +>T : T + + x = y; +>x = y : Diff +>x : T +>y : Diff + + y = x; // Error +>y = x : T +>y : Diff +>x : T + + let s1: string = x; // Error +>s1 : string +>x : T + + let s2: string = y; +>s2 : string +>y : Diff +} + +function f3(x: Partial[keyof T], y: NonNullable[keyof T]>) { +>f3 : (x: Partial[keyof T], y: Diff[keyof T], null | undefined>) => void +>T : T +>x : Partial[keyof T] +>Partial : Partial +>T : T +>T : T +>y : Diff[keyof T], null | undefined> +>NonNullable : Diff +>Partial : Partial +>T : T +>T : T + + x = y; +>x = y : Diff[keyof T], null | undefined> +>x : Partial[keyof T] +>y : Diff[keyof T], null | undefined> + + y = x; // Error +>y = x : Partial[keyof T] +>y : Diff[keyof T], null | undefined> +>x : Partial[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; // { k: "c", c: boolean } +>T10 : { k: "c"; c: boolean; } +>Diff : Diff +>Options : Options +>k : "a" | "b" + +type T11 = Filter; // { k: "a", a: number } | { k: "b", b: string } +>T11 : { k: "a"; a: number; } | { k: "b"; b: string; } +>Filter : Filter +>Options : Options +>k : "a" | "b" + +type T12 = Diff; // { k: "c", c: boolean } +>T12 : { k: "c"; c: boolean; } +>Diff : Diff +>Options : Options +>k : "a" +>k : "b" + +type T13 = Filter; // { k: "a", a: number } | { k: "b", b: string } +>T13 : { k: "a"; a: number; } | { k: "b"; b: string; } +>Filter : Filter +>Options : Options +>k : "a" +>k : "b" + +type T14 = Diff; // Options +>T14 : Options +>Diff : Diff +>Options : Options +>q : "a" + +type T15 = Filter; // never +>T15 : never +>Filter : Filter +>Options : Options +>q : "a" + +declare function f4(p: K): Filter; +>f4 : (p: K) => Filter +>T : T +>Options : Options +>K : K +>p : K +>K : K +>Filter : Filter +>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 : (p: K) => Filter +>"a" : "a" + +type OptionsOfKind = Filter; +>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 +>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 = Filter; +>Select : Filter +>T : T +>K : K +>T : T +>V : V +>T : T +>K : K +>Filter : Filter +>T : T +>P : P +>K : K +>V : V + +type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } +>T17 : { k: "a"; a: number; } | { k: "b"; b: string; } +>Select : Filter +>Options : Options + +type TypeName = +>TypeName : TypeName +>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 void)>; // "string" | "function" +>T20 : "string" | "function" +>TypeName : TypeName + +type T21 = TypeName; // "string" | "number" | "boolean" | "undefined" | "function" | "object" +>T21 : "string" | "number" | "boolean" | "undefined" | "object" | "function" +>TypeName : TypeName + +type T22 = TypeName; // "string" | "number" | "boolean" | "undefined" | "function" | "object" +>T22 : "string" | "number" | "boolean" | "undefined" | "object" | "function" +>TypeName : TypeName + +type T23 = TypeName<{}>; // "object" +>T23 : "object" +>TypeName : TypeName + +type KnockoutObservable = { object: T }; +>KnockoutObservable : KnockoutObservable +>T : T +>object : T +>T : T + +type KnockoutObservableArray = { array: T }; +>KnockoutObservableArray : KnockoutObservableArray +>T : T +>array : T +>T : T + +type KnockedOut = T extends any[] ? KnockoutObservableArray : KnockoutObservable; +>KnockedOut : KnockedOut +>T : T +>T : T +>KnockoutObservableArray : KnockoutObservableArray +>T : T +>KnockoutObservable : KnockoutObservable +>T : T + +type KnockedOutObj = { +>KnockedOutObj : KnockedOutObj +>T : T + + [P in keyof T]: KnockedOut; +>P : P +>T : T +>KnockedOut : KnockedOut +>T : T +>P : P +} + +interface Item { +>Item : Item + + id: number; +>id : number + + name: string; +>name : string + + subitems: string[]; +>subitems : string[] +} + +type KOItem = KnockedOutObj; +>KOItem : KnockedOutObj +>KnockedOutObj : KnockedOutObj +>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 = { [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 = Pick>; +>FunctionProperties : Pick +>T : T +>Pick : Pick +>T : T +>FunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T] +>T : T + +type NonFunctionPropertyNames = { [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 = Pick>; +>NonFunctionProperties : Pick +>T : T +>Pick : Pick +>T : T +>NonFunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T] +>T : T + +type T30 = FunctionProperties; +>T30 : Pick +>FunctionProperties : Pick +>Part : Part + +type T31 = NonFunctionProperties; +>T31 : Pick +>NonFunctionProperties : Pick +>Part : Part + +function f7(x: T, y: FunctionProperties, z: NonFunctionProperties) { +>f7 : (x: T, y: Pick, z: Pick) => void +>T : T +>x : T +>T : T +>y : Pick +>FunctionProperties : Pick +>T : T +>z : Pick +>NonFunctionProperties : Pick +>T : T + + x = y; // Error +>x = y : Pick +>x : T +>y : Pick + + x = z; // Error +>x = z : Pick +>x : T +>z : Pick + + y = x; +>y = x : T +>y : Pick +>x : T + + y = z; // Error +>y = z : Pick +>y : Pick +>z : Pick + + z = x; +>z = x : T +>z : Pick +>x : T + + z = y; // Error +>z = y : Pick +>z : Pick +>y : Pick +} + +function f8(x: keyof T, y: FunctionPropertyNames, z: NonFunctionPropertyNames) { +>f8 : (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 = +>DeepReadonly : DeepReadonly +>T : T + + T extends any[] ? DeepReadonlyArray : +>T : T +>DeepReadonlyArray : DeepReadonlyArray +>T : T + + T extends object ? DeepReadonlyObject : +>T : T +>DeepReadonlyObject : DeepReadonlyObject +>T : T + + T; +>T : T + +interface DeepReadonlyArray extends ReadonlyArray> {} +>DeepReadonlyArray : DeepReadonlyArray +>T : T +>ReadonlyArray : ReadonlyArray +>DeepReadonly : DeepReadonly +>T : T + +type DeepReadonlyObject = { +>DeepReadonlyObject : DeepReadonlyObject +>T : T + + readonly [P in NonFunctionPropertyNames]: DeepReadonly; +>P : P +>NonFunctionPropertyNames : { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T] +>T : T +>DeepReadonly : DeepReadonly +>T : T +>P : P + +}; + +function f10(part: DeepReadonly) { +>f10 : (part: DeepReadonlyObject) => void +>part : DeepReadonlyObject +>DeepReadonly : DeepReadonly +>Part : Part + + let name: string = part.name; +>name : string +>part.name : string +>part : DeepReadonlyObject +>name : string + + let id: number = part.subparts[0].id; +>id : number +>part.subparts[0].id : number +>part.subparts[0] : DeepReadonlyObject +>part.subparts : DeepReadonlyArray +>part : DeepReadonlyObject +>subparts : DeepReadonlyArray +>0 : 0 +>id : number + + part.id = part.id; // Error +>part.id = part.id : number +>part.id : any +>part : DeepReadonlyObject +>id : any +>part.id : number +>part : DeepReadonlyObject +>id : number + + part.subparts[0] = part.subparts[0]; // Error +>part.subparts[0] = part.subparts[0] : DeepReadonlyObject +>part.subparts[0] : DeepReadonlyObject +>part.subparts : DeepReadonlyArray +>part : DeepReadonlyObject +>subparts : DeepReadonlyArray +>0 : 0 +>part.subparts[0] : DeepReadonlyObject +>part.subparts : DeepReadonlyArray +>part : DeepReadonlyObject +>subparts : DeepReadonlyArray +>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.subparts : DeepReadonlyArray +>part : DeepReadonlyObject +>subparts : DeepReadonlyArray +>0 : 0 +>id : any +>part.subparts[0].id : number +>part.subparts[0] : DeepReadonlyObject +>part.subparts : DeepReadonlyArray +>part : DeepReadonlyObject +>subparts : DeepReadonlyArray +>0 : 0 +>id : number + + part.updatePart("hello"); // Error +>part.updatePart("hello") : any +>part.updatePart : any +>part : DeepReadonlyObject +>updatePart : any +>"hello" : "hello" +} + +type ZeroOf = T extends number ? 0 : T extends string ? "" : false; +>ZeroOf : ZeroOf +>T : T +>T : T +>T : T +>false : false + +function zeroOf(value: T) { +>zeroOf : (value: T) => ZeroOf +>T : T +>value : T +>T : T + + return >(typeof value === "number" ? 0 : typeof value === "string" ? "" : false); +>>(typeof value === "number" ? 0 : typeof value === "string" ? "" : false) : ZeroOf +>ZeroOf : ZeroOf +>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(n: number, b: boolean, x: number | boolean, y: T) { +>f20 : (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 : (value: T) => ZeroOf +>5 : 5 + + zeroOf("hello"); // "" +>zeroOf("hello") : "" +>zeroOf : (value: T) => ZeroOf +>"hello" : "hello" + + zeroOf(true); // false +>zeroOf(true) : false +>zeroOf : (value: T) => ZeroOf +>true : true + + zeroOf(n); // 0 +>zeroOf(n) : 0 +>zeroOf : (value: T) => ZeroOf +>n : number + + zeroOf(b); // False +>zeroOf(b) : false +>zeroOf : (value: T) => ZeroOf +>b : boolean + + zeroOf(x); // 0 | false +>zeroOf(x) : false | 0 +>zeroOf : (value: T) => ZeroOf +>x : number | boolean + + zeroOf(y); // ZeroOf +>zeroOf(y) : ZeroOf +>zeroOf : (value: T) => ZeroOf +>y : T +} + +function f21(x: T, y: ZeroOf) { +>f21 : (x: T, y: ZeroOf) => void +>T : T +>x : T +>T : T +>y : ZeroOf +>ZeroOf : ZeroOf +>T : T + + let z1: number | string = y; +>z1 : string | number +>y : ZeroOf + + let z2: 0 | "" = y; +>z2 : "" | 0 +>y : ZeroOf + + x = y; // Error +>x = y : ZeroOf +>x : T +>y : ZeroOf + + y = x; // Error +>y = x : T +>y : ZeroOf +>x : T +} + +type Extends = T extends U ? true : false; +>Extends : Extends +>T : T +>U : U +>T : T +>U : U +>true : true +>false : false + +type If = C extends true ? T : F; +>If : If +>C : C +>T : T +>F : F +>C : C +>true : true +>T : T +>F : F + +type Not = If; +>Not : If +>C : C +>If : If +>C : C +>false : false +>true : true + +type And = If; +>And : If +>A : A +>B : B +>If : If +>A : A +>B : B +>false : false + +type Or = If; +>Or : If +>A : A +>B : B +>If : If +>A : A +>true : true +>B : B + +type isString = Extends; +>isString : Extends +>T : T +>Extends : Extends +>T : T + +type Q1 = isString; // false +>Q1 : false +>isString : Extends + +type Q2 = isString<"abc">; // true +>Q2 : true +>isString : Extends + +type Q3 = isString; // boolean +>Q3 : boolean +>isString : Extends + +type Q4 = isString; // boolean +>Q4 : boolean +>isString : Extends + +type N1 = Not; // true +>N1 : true +>Not : If +>false : false + +type N2 = Not; // false +>N2 : false +>Not : If +>true : true + +type N3 = Not; // boolean +>N3 : boolean +>Not : If + +type A1 = And; // false +>A1 : false +>And : If +>false : false +>false : false + +type A2 = And; // false +>A2 : false +>And : If +>false : false +>true : true + +type A3 = And; // false +>A3 : false +>And : If +>true : true +>false : false + +type A4 = And; // true +>A4 : true +>And : If +>true : true +>true : true + +type A5 = And; // false +>A5 : false +>And : If +>false : false + +type A6 = And; // false +>A6 : false +>And : If +>false : false + +type A7 = And; // boolean +>A7 : boolean +>And : If +>true : true + +type A8 = And; // boolean +>A8 : boolean +>And : If +>true : true + +type A9 = And; // boolean +>A9 : boolean +>And : If + +type O1 = Or; // false +>O1 : false +>Or : If +>false : false +>false : false + +type O2 = Or; // true +>O2 : true +>Or : If +>false : false +>true : true + +type O3 = Or; // true +>O3 : true +>Or : If +>true : true +>false : false + +type O4 = Or; // true +>O4 : true +>Or : If +>true : true +>true : true + +type O5 = Or; // boolean +>O5 : boolean +>Or : If +>false : false + +type O6 = Or; // boolean +>O6 : boolean +>Or : If +>false : false + +type O7 = Or; // true +>O7 : true +>Or : If +>true : true + +type O8 = Or; // true +>O8 : true +>Or : If +>true : true + +type O9 = Or; // boolean +>O9 : boolean +>Or : If +