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:
@@ -20,32 +20,39 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(106,5): error TS2
|
||||
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 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'string' 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'.
|
||||
Type 'string' 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 'string | number | symbol' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'string' 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'.
|
||||
Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'string' 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 'never'.
|
||||
Type 'string' is not assignable to type 'never'.
|
||||
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 'never'.
|
||||
Type 'string | number | symbol' is not assignable to type 'never'.
|
||||
Type 'string' is not assignable to type 'never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(108,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 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'string' 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'.
|
||||
Type 'string' 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 'string | number | symbol' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'string' 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'.
|
||||
Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'string' 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 '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 'never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(114,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'string' 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'.
|
||||
Type 'string' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'string | number | symbol' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'string' 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'.
|
||||
Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'string' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(115,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]'.
|
||||
@@ -53,12 +60,15 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(115,5): error TS2
|
||||
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 'never'.
|
||||
Type 'string' is not assignable to type 'never'.
|
||||
Type 'string | number | symbol' is not assignable to type 'never'.
|
||||
Type 'string' is not assignable to type 'never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(116,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'string' 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'.
|
||||
Type 'string' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'string | number | symbol' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'string' 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'.
|
||||
Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'string' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(117,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]'.
|
||||
@@ -221,15 +231,18 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
|
||||
!!! 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 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' 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'.
|
||||
!!! error TS2322: Type 'string' 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 'string | number | symbol' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' 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'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type 'string' 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 'never'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'never'.
|
||||
!!! 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 'never'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'never'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'never'.
|
||||
z = x;
|
||||
z = y; // Error
|
||||
~
|
||||
@@ -237,14 +250,16 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
|
||||
!!! 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 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' 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'.
|
||||
!!! error TS2322: Type 'string' 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 'string | number | symbol' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' 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'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type 'string' 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 '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 'never'.
|
||||
}
|
||||
|
||||
function f8<T>(x: keyof T, y: FunctionPropertyNames<T>, z: NonFunctionPropertyNames<T>) {
|
||||
@@ -253,10 +268,12 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
|
||||
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 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' 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'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' 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'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
!!! error TS2322: Type 'string' 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]'.
|
||||
@@ -266,14 +283,17 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
|
||||
!!! 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 'never'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'never'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'never'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type '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 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' 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'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
!!! error TS2322: Type 'string' 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'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
!!! error TS2322: Type 'string' 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]'.
|
||||
@@ -491,7 +511,7 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
|
||||
|
||||
// Repro from #21862
|
||||
|
||||
type OldDiff<T extends string, U extends string> = (
|
||||
type OldDiff<T extends keyof any, U extends keyof any> = (
|
||||
& { [P in T]: P; }
|
||||
& { [P in U]: never; }
|
||||
& { [x: string]: never; }
|
||||
|
||||
@@ -301,7 +301,7 @@ function f50() {
|
||||
|
||||
// Repro from #21862
|
||||
|
||||
type OldDiff<T extends string, U extends string> = (
|
||||
type OldDiff<T extends keyof any, U extends keyof any> = (
|
||||
& { [P in T]: P; }
|
||||
& { [P in U]: never; }
|
||||
& { [x: string]: never; }
|
||||
@@ -656,7 +656,7 @@ declare type T95<T> = T extends string ? boolean : number;
|
||||
declare const f44: <U>(value: T94<U>) => T95<U>;
|
||||
declare const f45: <U>(value: T95<U>) => T94<U>;
|
||||
declare function f50(): void;
|
||||
declare type OldDiff<T extends string, U extends string> = ({
|
||||
declare type OldDiff<T extends keyof any, U extends keyof any> = ({
|
||||
[P in T]: P;
|
||||
} & {
|
||||
[P in U]: never;
|
||||
|
||||
@@ -1186,10 +1186,10 @@ function f50() {
|
||||
|
||||
// Repro from #21862
|
||||
|
||||
type OldDiff<T extends string, U extends string> = (
|
||||
type OldDiff<T extends keyof any, U extends keyof any> = (
|
||||
>OldDiff : Symbol(OldDiff, Decl(conditionalTypes1.ts, 298, 1))
|
||||
>T : Symbol(T, Decl(conditionalTypes1.ts, 302, 13))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 302, 30))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 302, 33))
|
||||
|
||||
& { [P in T]: P; }
|
||||
>P : Symbol(P, Decl(conditionalTypes1.ts, 303, 9))
|
||||
@@ -1198,7 +1198,7 @@ type OldDiff<T extends string, U extends string> = (
|
||||
|
||||
& { [P in U]: never; }
|
||||
>P : Symbol(P, Decl(conditionalTypes1.ts, 304, 9))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 302, 30))
|
||||
>U : Symbol(U, Decl(conditionalTypes1.ts, 302, 33))
|
||||
|
||||
& { [x: string]: never; }
|
||||
>x : Symbol(x, Decl(conditionalTypes1.ts, 305, 9))
|
||||
|
||||
@@ -1343,7 +1343,7 @@ function f50() {
|
||||
|
||||
// Repro from #21862
|
||||
|
||||
type OldDiff<T extends string, U extends string> = (
|
||||
type OldDiff<T extends keyof any, U extends keyof any> = (
|
||||
>OldDiff : ({ [P in T]: P; } & { [P in U]: never; } & { [x: string]: never; })[T]
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
@@ -6,7 +6,8 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(24,5): error TS23
|
||||
Types of property 'foo' are incompatible.
|
||||
Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'.
|
||||
Type 'keyof B' is not assignable to type 'keyof A'.
|
||||
Type 'string' is not assignable to type 'keyof A'.
|
||||
Type 'string | number | symbol' is not assignable to type 'keyof A'.
|
||||
Type 'string' is not assignable to type 'keyof A'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes2.ts(25,5): error TS2322: Type 'Invariant<A>' is not assignable to type 'Invariant<B>'.
|
||||
Types of property 'foo' are incompatible.
|
||||
Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'.
|
||||
@@ -61,7 +62,8 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2
|
||||
!!! error TS2322: Types of property 'foo' are incompatible.
|
||||
!!! error TS2322: Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'.
|
||||
!!! error TS2322: Type 'keyof B' is not assignable to type 'keyof A'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'keyof A'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'keyof A'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'keyof A'.
|
||||
b = a; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'Invariant<A>' is not assignable to type 'Invariant<B>'.
|
||||
|
||||
@@ -6,7 +6,7 @@ interface DataSnapshot<X = {}> {
|
||||
}
|
||||
|
||||
interface Snapshot<T> extends DataSnapshot {
|
||||
child<U extends keyof T>(path: U): Snapshot<T[U]>;
|
||||
child<U extends Extract<keyof T, string>>(path: U): Snapshot<T[U]>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,11 +16,12 @@ interface Snapshot<T> extends DataSnapshot {
|
||||
>T : Symbol(T, Decl(deeplyNestedCheck.ts, 6, 19))
|
||||
>DataSnapshot : Symbol(DataSnapshot, Decl(deeplyNestedCheck.ts, 0, 0))
|
||||
|
||||
child<U extends keyof T>(path: U): Snapshot<T[U]>;
|
||||
child<U extends Extract<keyof T, string>>(path: U): Snapshot<T[U]>;
|
||||
>child : Symbol(Snapshot.child, Decl(deeplyNestedCheck.ts, 6, 44))
|
||||
>U : Symbol(U, Decl(deeplyNestedCheck.ts, 7, 8))
|
||||
>Extract : Symbol(Extract, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(deeplyNestedCheck.ts, 6, 19))
|
||||
>path : Symbol(path, Decl(deeplyNestedCheck.ts, 7, 27))
|
||||
>path : Symbol(path, Decl(deeplyNestedCheck.ts, 7, 44))
|
||||
>U : Symbol(U, Decl(deeplyNestedCheck.ts, 7, 8))
|
||||
>Snapshot : Symbol(Snapshot, Decl(deeplyNestedCheck.ts, 4, 1))
|
||||
>T : Symbol(T, Decl(deeplyNestedCheck.ts, 6, 19))
|
||||
|
||||
@@ -16,9 +16,10 @@ interface Snapshot<T> extends DataSnapshot {
|
||||
>T : T
|
||||
>DataSnapshot : DataSnapshot<X>
|
||||
|
||||
child<U extends keyof T>(path: U): Snapshot<T[U]>;
|
||||
>child : <U extends keyof T>(path: U) => Snapshot<T[U]>
|
||||
child<U extends Extract<keyof T, string>>(path: U): Snapshot<T[U]>;
|
||||
>child : <U extends Extract<keyof T, string>>(path: U) => Snapshot<T[U]>
|
||||
>U : U
|
||||
>Extract : Extract<T, U>
|
||||
>T : T
|
||||
>path : U
|
||||
>U : U
|
||||
|
||||
@@ -6,7 +6,7 @@ type StringContains<S extends string, L extends string> = (
|
||||
{ [key: string]: 'false' }
|
||||
)[L]
|
||||
|
||||
type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>
|
||||
type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L>
|
||||
|
||||
type First<T> = ObjectHasKey<T, '0'>; // Should be deferred
|
||||
|
||||
@@ -43,7 +43,7 @@ declare type StringContains<S extends string, L extends string> = ({
|
||||
} & {
|
||||
[key: string]: 'false';
|
||||
})[L];
|
||||
declare type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>;
|
||||
declare type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L>;
|
||||
declare type First<T> = ObjectHasKey<T, '0'>;
|
||||
declare type T1 = ObjectHasKey<{
|
||||
a: string;
|
||||
|
||||
@@ -16,16 +16,17 @@ type StringContains<S extends string, L extends string> = (
|
||||
)[L]
|
||||
>L : Symbol(L, Decl(deferredLookupTypeResolution.ts, 2, 37))
|
||||
|
||||
type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>
|
||||
type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L>
|
||||
>ObjectHasKey : Symbol(ObjectHasKey, Decl(deferredLookupTypeResolution.ts, 5, 6))
|
||||
>O : Symbol(O, Decl(deferredLookupTypeResolution.ts, 7, 18))
|
||||
>L : Symbol(L, Decl(deferredLookupTypeResolution.ts, 7, 20))
|
||||
>StringContains : Symbol(StringContains, Decl(deferredLookupTypeResolution.ts, 0, 0))
|
||||
>Extract : Symbol(Extract, Decl(lib.d.ts, --, --))
|
||||
>O : Symbol(O, Decl(deferredLookupTypeResolution.ts, 7, 18))
|
||||
>L : Symbol(L, Decl(deferredLookupTypeResolution.ts, 7, 20))
|
||||
|
||||
type First<T> = ObjectHasKey<T, '0'>; // Should be deferred
|
||||
>First : Symbol(First, Decl(deferredLookupTypeResolution.ts, 7, 67))
|
||||
>First : Symbol(First, Decl(deferredLookupTypeResolution.ts, 7, 84))
|
||||
>T : Symbol(T, Decl(deferredLookupTypeResolution.ts, 9, 11))
|
||||
>ObjectHasKey : Symbol(ObjectHasKey, Decl(deferredLookupTypeResolution.ts, 5, 6))
|
||||
>T : Symbol(T, Decl(deferredLookupTypeResolution.ts, 9, 11))
|
||||
|
||||
@@ -16,28 +16,29 @@ type StringContains<S extends string, L extends string> = (
|
||||
)[L]
|
||||
>L : L
|
||||
|
||||
type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L>
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>O : O
|
||||
>L : L
|
||||
>StringContains : ({ [K in S]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>Extract : Extract<T, U>
|
||||
>O : O
|
||||
>L : L
|
||||
|
||||
type First<T> = ObjectHasKey<T, '0'>; // Should be deferred
|
||||
>First : ({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["0"]
|
||||
>First : ({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["0"]
|
||||
>T : T
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>T : T
|
||||
|
||||
type T1 = ObjectHasKey<{ a: string }, 'a'>; // 'true'
|
||||
>T1 : "true"
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>a : string
|
||||
|
||||
type T2 = ObjectHasKey<{ a: string }, 'b'>; // 'false'
|
||||
>T2 : "false"
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>a : string
|
||||
|
||||
// Verify that mapped type isn't eagerly resolved in type-to-string operation
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/deferredLookupTypeResolution2.ts(14,13): error TS2536: Type '({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]' cannot be used to index type '{ true: "true"; }'.
|
||||
tests/cases/compiler/deferredLookupTypeResolution2.ts(19,21): error TS2536: Type '({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]]' cannot be used to index type '{ true: "true"; }'.
|
||||
tests/cases/compiler/deferredLookupTypeResolution2.ts(14,13): error TS2536: Type '({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]' cannot be used to index type '{ true: "true"; }'.
|
||||
tests/cases/compiler/deferredLookupTypeResolution2.ts(19,21): error TS2536: Type '({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]]' cannot be used to index type '{ true: "true"; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/deferredLookupTypeResolution2.ts (2 errors) ====
|
||||
@@ -7,7 +7,7 @@ tests/cases/compiler/deferredLookupTypeResolution2.ts(19,21): error TS2536: Type
|
||||
|
||||
type StringContains<S extends string, L extends string> = ({ [K in S]: 'true' } & { [key: string]: 'false'})[L];
|
||||
|
||||
type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>;
|
||||
type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L>;
|
||||
|
||||
type A<T> = ObjectHasKey<T, '0'>;
|
||||
|
||||
@@ -18,14 +18,14 @@ tests/cases/compiler/deferredLookupTypeResolution2.ts(19,21): error TS2536: Type
|
||||
// Error, "false" not handled
|
||||
type E<T> = { true: 'true' }[ObjectHasKey<T, '1'>];
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2536: Type '({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]' cannot be used to index type '{ true: "true"; }'.
|
||||
!!! error TS2536: Type '({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]' cannot be used to index type '{ true: "true"; }'.
|
||||
|
||||
type Juxtapose<T> = ({ true: 'otherwise' } & { [k: string]: 'true' })[ObjectHasKey<T, '1'>];
|
||||
|
||||
// Error, "otherwise" is missing
|
||||
type DeepError<T> = { true: 'true' }[Juxtapose<T>];
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2536: Type '({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]]' cannot be used to index type '{ true: "true"; }'.
|
||||
!!! error TS2536: Type '({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]]' cannot be used to index type '{ true: "true"; }'.
|
||||
|
||||
type DeepOK<T> = { true: 'true', otherwise: 'false' }[Juxtapose<T>];
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
type StringContains<S extends string, L extends string> = ({ [K in S]: 'true' } & { [key: string]: 'false'})[L];
|
||||
|
||||
type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>;
|
||||
type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L>;
|
||||
|
||||
type A<T> = ObjectHasKey<T, '0'>;
|
||||
|
||||
@@ -33,7 +33,7 @@ declare type StringContains<S extends string, L extends string> = ({
|
||||
} & {
|
||||
[key: string]: 'false';
|
||||
})[L];
|
||||
declare type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>;
|
||||
declare type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L>;
|
||||
declare type A<T> = ObjectHasKey<T, '0'>;
|
||||
declare type B = ObjectHasKey<[string, number], '1'>;
|
||||
declare type C = ObjectHasKey<[string, number], '2'>;
|
||||
|
||||
@@ -10,16 +10,17 @@ type StringContains<S extends string, L extends string> = ({ [K in S]: 'true' }
|
||||
>key : Symbol(key, Decl(deferredLookupTypeResolution2.ts, 2, 85))
|
||||
>L : Symbol(L, Decl(deferredLookupTypeResolution2.ts, 2, 37))
|
||||
|
||||
type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>;
|
||||
type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L>;
|
||||
>ObjectHasKey : Symbol(ObjectHasKey, Decl(deferredLookupTypeResolution2.ts, 2, 112))
|
||||
>O : Symbol(O, Decl(deferredLookupTypeResolution2.ts, 4, 18))
|
||||
>L : Symbol(L, Decl(deferredLookupTypeResolution2.ts, 4, 20))
|
||||
>StringContains : Symbol(StringContains, Decl(deferredLookupTypeResolution2.ts, 0, 0))
|
||||
>Extract : Symbol(Extract, Decl(lib.d.ts, --, --))
|
||||
>O : Symbol(O, Decl(deferredLookupTypeResolution2.ts, 4, 18))
|
||||
>L : Symbol(L, Decl(deferredLookupTypeResolution2.ts, 4, 20))
|
||||
|
||||
type A<T> = ObjectHasKey<T, '0'>;
|
||||
>A : Symbol(A, Decl(deferredLookupTypeResolution2.ts, 4, 68))
|
||||
>A : Symbol(A, Decl(deferredLookupTypeResolution2.ts, 4, 85))
|
||||
>T : Symbol(T, Decl(deferredLookupTypeResolution2.ts, 6, 7))
|
||||
>ObjectHasKey : Symbol(ObjectHasKey, Decl(deferredLookupTypeResolution2.ts, 2, 112))
|
||||
>T : Symbol(T, Decl(deferredLookupTypeResolution2.ts, 6, 7))
|
||||
@@ -34,7 +35,7 @@ type C = ObjectHasKey<[string, number], '2'>; // "false"
|
||||
|
||||
type D = A<[string]>; // "true"
|
||||
>D : Symbol(D, Decl(deferredLookupTypeResolution2.ts, 9, 45))
|
||||
>A : Symbol(A, Decl(deferredLookupTypeResolution2.ts, 4, 68))
|
||||
>A : Symbol(A, Decl(deferredLookupTypeResolution2.ts, 4, 85))
|
||||
|
||||
// Error, "false" not handled
|
||||
type E<T> = { true: 'true' }[ObjectHasKey<T, '1'>];
|
||||
|
||||
@@ -10,61 +10,62 @@ type StringContains<S extends string, L extends string> = ({ [K in S]: 'true' }
|
||||
>key : string
|
||||
>L : L
|
||||
|
||||
type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>;
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
type ObjectHasKey<O, L extends string> = StringContains<Extract<keyof O, string>, L>;
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>O : O
|
||||
>L : L
|
||||
>StringContains : ({ [K in S]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>Extract : Extract<T, U>
|
||||
>O : O
|
||||
>L : L
|
||||
|
||||
type A<T> = ObjectHasKey<T, '0'>;
|
||||
>A : ({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["0"]
|
||||
>A : ({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["0"]
|
||||
>T : T
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>T : T
|
||||
|
||||
type B = ObjectHasKey<[string, number], '1'>; // "true"
|
||||
>B : "true"
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
|
||||
type C = ObjectHasKey<[string, number], '2'>; // "false"
|
||||
>C : "false"
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
|
||||
type D = A<[string]>; // "true"
|
||||
>D : "true"
|
||||
>A : ({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["0"]
|
||||
>A : ({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["0"]
|
||||
|
||||
// Error, "false" not handled
|
||||
type E<T> = { true: 'true' }[ObjectHasKey<T, '1'>];
|
||||
>E : { true: "true"; }[({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]]
|
||||
>E : { true: "true"; }[({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]]
|
||||
>T : T
|
||||
>true : "true"
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>T : T
|
||||
|
||||
type Juxtapose<T> = ({ true: 'otherwise' } & { [k: string]: 'true' })[ObjectHasKey<T, '1'>];
|
||||
>Juxtapose : ({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]]
|
||||
>Juxtapose : ({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]]
|
||||
>T : T
|
||||
>true : "otherwise"
|
||||
>k : string
|
||||
>ObjectHasKey : ({ [K in keyof O]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>ObjectHasKey : ({ [K in Extract<keyof O, string>]: "true"; } & { [key: string]: "false"; })[L]
|
||||
>T : T
|
||||
|
||||
// Error, "otherwise" is missing
|
||||
type DeepError<T> = { true: 'true' }[Juxtapose<T>];
|
||||
>DeepError : { true: "true"; }[({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]]]
|
||||
>DeepError : { true: "true"; }[({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]]]
|
||||
>T : T
|
||||
>true : "true"
|
||||
>Juxtapose : ({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]]
|
||||
>Juxtapose : ({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]]
|
||||
>T : T
|
||||
|
||||
type DeepOK<T> = { true: 'true', otherwise: 'false' }[Juxtapose<T>];
|
||||
>DeepOK : { true: "true"; otherwise: "false"; }[({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]]]
|
||||
>DeepOK : { true: "true"; otherwise: "false"; }[({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]]]
|
||||
>T : T
|
||||
>true : "true"
|
||||
>otherwise : "false"
|
||||
>Juxtapose : ({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in keyof T]: "true"; } & { [key: string]: "false"; })["1"]]
|
||||
>Juxtapose : ({ true: "otherwise"; } & { [k: string]: "true"; })[({ [K in Extract<keyof T, string>]: "true"; } & { [key: string]: "false"; })["1"]]
|
||||
>T : T
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(33,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(50,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(33,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'Extract<keyof this, string>'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(50,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'Extract<keyof this, string>'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(79,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'Color.Blue'.
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(79,15):
|
||||
for (var x in this.biz) { }
|
||||
for (var x in this) { }
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'Extract<keyof this, string>'.
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(79,15):
|
||||
for (var x in this.biz) { }
|
||||
for (var x in this) { }
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'Extract<keyof this, string>'.
|
||||
|
||||
for (var x in super.biz) { }
|
||||
for (var x in super.biz()) { }
|
||||
|
||||
@@ -9,10 +9,10 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(1
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(20,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'string'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(22,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'string'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(29,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(31,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(31,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'Extract<keyof this, string>'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(38,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(46,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(48,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(48,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'Extract<keyof this, string>'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(51,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(62,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type 'number'.
|
||||
|
||||
@@ -72,7 +72,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6
|
||||
for (var x in this.biz) { }
|
||||
for (var x in this) { }
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'Extract<keyof this, string>'.
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6
|
||||
for (var x in this.biz) { }
|
||||
for (var x in this) { }
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'Extract<keyof this, string>'.
|
||||
|
||||
for (var x in super.biz) { }
|
||||
for (var x in super.biz()) { }
|
||||
|
||||
@@ -8,7 +8,7 @@ function F<T>() {
|
||||
>T : T
|
||||
|
||||
for (var a in expr) {
|
||||
>a : keyof T
|
||||
>a : Extract<keyof T, string>
|
||||
>expr : T
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class C {
|
||||
>temp : () => void
|
||||
|
||||
for (var x in this) {
|
||||
>x : keyof this
|
||||
>x : Extract<keyof this, string>
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class C<T> {
|
||||
>T : T
|
||||
|
||||
for (var p in x) {
|
||||
>p : keyof T
|
||||
>p : Extract<keyof T, string>
|
||||
>x : T
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//// [indexedAccessRetainsIndexSignature.ts]
|
||||
type Diff<T extends string, U extends string> =
|
||||
type Diff<T extends keyof any, U extends keyof any> =
|
||||
({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]
|
||||
type Omit<U, K extends keyof U> = Pick<U, Diff<keyof U, K>>
|
||||
type Omit1<U, K extends keyof U> = Pick<U, Diff<keyof U, K>>;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
=== tests/cases/compiler/indexedAccessRetainsIndexSignature.ts ===
|
||||
type Diff<T extends string, U extends string> =
|
||||
type Diff<T extends keyof any, U extends keyof any> =
|
||||
>Diff : Symbol(Diff, Decl(indexedAccessRetainsIndexSignature.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(indexedAccessRetainsIndexSignature.ts, 0, 10))
|
||||
>U : Symbol(U, Decl(indexedAccessRetainsIndexSignature.ts, 0, 27))
|
||||
>U : Symbol(U, Decl(indexedAccessRetainsIndexSignature.ts, 0, 30))
|
||||
|
||||
({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]
|
||||
>P : Symbol(P, Decl(indexedAccessRetainsIndexSignature.ts, 1, 8))
|
||||
>T : Symbol(T, Decl(indexedAccessRetainsIndexSignature.ts, 0, 10))
|
||||
>P : Symbol(P, Decl(indexedAccessRetainsIndexSignature.ts, 1, 8))
|
||||
>P : Symbol(P, Decl(indexedAccessRetainsIndexSignature.ts, 1, 26))
|
||||
>U : Symbol(U, Decl(indexedAccessRetainsIndexSignature.ts, 0, 27))
|
||||
>U : Symbol(U, Decl(indexedAccessRetainsIndexSignature.ts, 0, 30))
|
||||
>x : Symbol(x, Decl(indexedAccessRetainsIndexSignature.ts, 1, 48))
|
||||
>T : Symbol(T, Decl(indexedAccessRetainsIndexSignature.ts, 0, 10))
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/compiler/indexedAccessRetainsIndexSignature.ts ===
|
||||
type Diff<T extends string, U extends string> =
|
||||
type Diff<T extends keyof any, U extends keyof any> =
|
||||
>Diff : ({ [P in T]: P; } & { [P in U]: never; } & { [x: string]: never; })[T]
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
@@ -125,14 +125,14 @@ interface P {
|
||||
}
|
||||
|
||||
type NonIndexableUnion2 = string | number;
|
||||
>NonIndexableUnion2 : string | number
|
||||
>NonIndexableUnion2 : NonIndexableUnion2
|
||||
|
||||
interface Q {
|
||||
>Q : Q
|
||||
|
||||
[u: NonIndexableUnion2]: A;
|
||||
>u : string | number
|
||||
>NonIndexableUnion2 : string | number
|
||||
>u : NonIndexableUnion2
|
||||
>NonIndexableUnion2 : NonIndexableUnion2
|
||||
>A : A
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(75,43): error TS2304: C
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(75,43): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(82,44): error TS2344: Type 'U' does not satisfy the constraint 'string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
|
||||
Type 'T' is not assignable to type 'symbol'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/conditional/inferTypes1.ts (16 errors) ====
|
||||
@@ -200,7 +201,8 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322:
|
||||
type A<T> = T extends string ? { [P in T]: void; } : T;
|
||||
type B<T> = string extends T ? { [P in T]: void; } : T; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'symbol'.
|
||||
|
||||
// Repro from #22302
|
||||
|
||||
|
||||
@@ -64,19 +64,19 @@ function boxify<T>(obj: T): Boxified<T> {
|
||||
>T : T
|
||||
|
||||
for (let k in obj) {
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
>obj : T
|
||||
|
||||
result[k] = box(obj[k]);
|
||||
>result[k] = box(obj[k]) : Box<T[keyof T]>
|
||||
>result[k] : Boxified<T>[keyof T]
|
||||
>result[k] = box(obj[k]) : Box<T[Extract<keyof T, string>]>
|
||||
>result[k] : Boxified<T>[Extract<keyof T, string>]
|
||||
>result : Boxified<T>
|
||||
>k : keyof T
|
||||
>box(obj[k]) : Box<T[keyof T]>
|
||||
>k : Extract<keyof T, string>
|
||||
>box(obj[k]) : Box<T[Extract<keyof T, string>]>
|
||||
>box : <T>(x: T) => Box<T>
|
||||
>obj[k] : T[keyof T]
|
||||
>obj[k] : T[Extract<keyof T, string>]
|
||||
>obj : T
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
}
|
||||
return result;
|
||||
>result : Boxified<T>
|
||||
@@ -97,19 +97,19 @@ function unboxify<T>(obj: Boxified<T>): T {
|
||||
>T : T
|
||||
|
||||
for (let k in obj) {
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
>obj : Boxified<T>
|
||||
|
||||
result[k] = unbox(obj[k]);
|
||||
>result[k] = unbox(obj[k]) : T[keyof T]
|
||||
>result[k] : T[keyof T]
|
||||
>result[k] = unbox(obj[k]) : T[Extract<keyof T, string>]
|
||||
>result[k] : T[Extract<keyof T, string>]
|
||||
>result : T
|
||||
>k : keyof T
|
||||
>unbox(obj[k]) : T[keyof T]
|
||||
>k : Extract<keyof T, string>
|
||||
>unbox(obj[k]) : T[Extract<keyof T, string>]
|
||||
>unbox : <T>(x: Box<T>) => T
|
||||
>obj[k] : Boxified<T>[keyof T]
|
||||
>obj[k] : Boxified<T>[Extract<keyof T, string>]
|
||||
>obj : Boxified<T>
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
}
|
||||
return result;
|
||||
>result : T
|
||||
@@ -125,19 +125,19 @@ function assignBoxified<T>(obj: Boxified<T>, values: T) {
|
||||
>T : T
|
||||
|
||||
for (let k in values) {
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
>values : T
|
||||
|
||||
obj[k].value = values[k];
|
||||
>obj[k].value = values[k] : T[keyof T]
|
||||
>obj[k].value : T[keyof T]
|
||||
>obj[k] : Boxified<T>[keyof T]
|
||||
>obj[k].value = values[k] : T[Extract<keyof T, string>]
|
||||
>obj[k].value : T[Extract<keyof T, string>]
|
||||
>obj[k] : Boxified<T>[Extract<keyof T, string>]
|
||||
>obj : Boxified<T>
|
||||
>k : keyof T
|
||||
>value : T[keyof T]
|
||||
>values[k] : T[keyof T]
|
||||
>k : Extract<keyof T, string>
|
||||
>value : T[Extract<keyof T, string>]
|
||||
>values[k] : T[Extract<keyof T, string>]
|
||||
>values : T
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,14 +33,14 @@ function f1<K extends string, T>(obj: { [P in K]: T }, k: K) {
|
||||
>k1 : K
|
||||
}
|
||||
for (let k2 in obj) {
|
||||
>k2 : K
|
||||
>k2 : Extract<K, string>
|
||||
>obj : { [P in K]: T; }
|
||||
|
||||
let x2 = obj[k2];
|
||||
>x2 : { [P in K]: T; }[K]
|
||||
>obj[k2] : { [P in K]: T; }[K]
|
||||
>x2 : { [P in K]: T; }[Extract<K, string>]
|
||||
>obj[k2] : { [P in K]: T; }[Extract<K, string>]
|
||||
>obj : { [P in K]: T; }
|
||||
>k2 : K
|
||||
>k2 : Extract<K, string>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,14 +76,14 @@ function f2<T>(obj: { [P in keyof T]: T[P] }, k: keyof T) {
|
||||
>k1 : keyof T
|
||||
}
|
||||
for (let k2 in obj) {
|
||||
>k2 : keyof T
|
||||
>k2 : Extract<keyof T, string>
|
||||
>obj : { [P in keyof T]: T[P]; }
|
||||
|
||||
let x2 = obj[k2];
|
||||
>x2 : { [P in keyof T]: T[P]; }[keyof T]
|
||||
>obj[k2] : { [P in keyof T]: T[P]; }[keyof T]
|
||||
>x2 : { [P in keyof T]: T[P]; }[Extract<keyof T, string>]
|
||||
>obj[k2] : { [P in keyof T]: T[P]; }[Extract<keyof T, string>]
|
||||
>obj : { [P in keyof T]: T[P]; }
|
||||
>k2 : keyof T
|
||||
>k2 : Extract<keyof T, string>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ function f3<T, K extends keyof T>(obj: { [P in K]: T[P] }, k: K) {
|
||||
>k1 : K
|
||||
}
|
||||
for (let k2 in obj) {
|
||||
>k2 : K
|
||||
>k2 : Extract<K, string>
|
||||
>obj : { [P in K]: T[P]; }
|
||||
|
||||
let x2 = obj[k2];
|
||||
>x2 : { [P in K]: T[P]; }[K]
|
||||
>obj[k2] : { [P in K]: T[P]; }[K]
|
||||
>x2 : { [P in K]: T[P]; }[Extract<K, string>]
|
||||
>obj[k2] : { [P in K]: T[P]; }[Extract<K, string>]
|
||||
>obj : { [P in K]: T[P]; }
|
||||
>k2 : K
|
||||
>k2 : Extract<K, string>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ class AnotherSampleClass<T> extends SampleClass<T & Foo> {
|
||||
new AnotherSampleClass({});
|
||||
|
||||
// Positive repro from #17166
|
||||
function f3<T, K extends keyof T>(t: T, k: K, tk: T[K]): void {
|
||||
function f3<T, K extends Extract<keyof T, string>>(t: T, k: K, tk: T[K]): void {
|
||||
for (let key in t) {
|
||||
key = k // ok, K ==> keyof T
|
||||
t[key] = tk; // ok, T[K] ==> T[keyof T]
|
||||
@@ -1208,7 +1208,7 @@ declare class AnotherSampleClass<T> extends SampleClass<T & Foo> {
|
||||
constructor(props: T);
|
||||
brokenMethod(): void;
|
||||
}
|
||||
declare function f3<T, K extends keyof T>(t: T, k: K, tk: T[K]): void;
|
||||
declare function f3<T, K extends Extract<keyof T, string>>(t: T, k: K, tk: T[K]): void;
|
||||
declare type Predicates<TaggedRecord> = {
|
||||
[T in keyof TaggedRecord]: (variant: TaggedRecord[keyof TaggedRecord]) => variant is TaggedRecord[T];
|
||||
};
|
||||
|
||||
@@ -1963,31 +1963,32 @@ new AnotherSampleClass({});
|
||||
>AnotherSampleClass : Symbol(AnotherSampleClass, Decl(keyofAndIndexedAccess.ts, 540, 54))
|
||||
|
||||
// Positive repro from #17166
|
||||
function f3<T, K extends keyof T>(t: T, k: K, tk: T[K]): void {
|
||||
function f3<T, K extends Extract<keyof T, string>>(t: T, k: K, tk: T[K]): void {
|
||||
>f3 : Symbol(f3, Decl(keyofAndIndexedAccess.ts, 552, 27))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 555, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 555, 14))
|
||||
>Extract : Symbol(Extract, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 555, 12))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 555, 34))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 555, 51))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 555, 12))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 555, 39))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 555, 56))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 555, 14))
|
||||
>tk : Symbol(tk, Decl(keyofAndIndexedAccess.ts, 555, 45))
|
||||
>tk : Symbol(tk, Decl(keyofAndIndexedAccess.ts, 555, 62))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 555, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 555, 14))
|
||||
|
||||
for (let key in t) {
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 556, 12))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 555, 34))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 555, 51))
|
||||
|
||||
key = k // ok, K ==> keyof T
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 556, 12))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 555, 39))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 555, 56))
|
||||
|
||||
t[key] = tk; // ok, T[K] ==> T[keyof T]
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 555, 34))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 555, 51))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 556, 12))
|
||||
>tk : Symbol(tk, Decl(keyofAndIndexedAccess.ts, 555, 45))
|
||||
>tk : Symbol(tk, Decl(keyofAndIndexedAccess.ts, 555, 62))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ const enum E { A, B, C }
|
||||
>C : E.C
|
||||
|
||||
type K00 = keyof any; // string
|
||||
>K00 : string
|
||||
>K00 : string | number | symbol
|
||||
|
||||
type K01 = keyof string; // "toString" | "charAt" | ...
|
||||
>K01 : "length" | "toString" | "concat" | "slice" | "indexOf" | "lastIndexOf" | "charAt" | "charCodeAt" | "localeCompare" | "match" | "replace" | "search" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr" | "valueOf"
|
||||
>K01 : number | "length" | "toString" | "concat" | "slice" | "indexOf" | "lastIndexOf" | "charAt" | "charCodeAt" | "localeCompare" | "match" | "replace" | "search" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr" | "valueOf"
|
||||
|
||||
type K02 = keyof number; // "toString" | "toFixed" | "toExponential" | ...
|
||||
>K02 : "toString" | "toLocaleString" | "valueOf" | "toFixed" | "toExponential" | "toPrecision"
|
||||
@@ -88,11 +88,11 @@ type K10 = keyof Shape; // "name" | "width" | "height" | "visible"
|
||||
>Shape : Shape
|
||||
|
||||
type K11 = keyof Shape[]; // "length" | "toString" | ...
|
||||
>K11 : "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
>K11 : number | "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
>Shape : Shape
|
||||
|
||||
type K12 = keyof Dictionary<Shape>; // string
|
||||
>K12 : string
|
||||
>K12 : string | number | symbol
|
||||
>Dictionary : Dictionary<T>
|
||||
>Shape : Shape
|
||||
|
||||
@@ -108,7 +108,7 @@ type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ...
|
||||
>E : E
|
||||
|
||||
type K16 = keyof [string, number]; // "0" | "1" | "length" | "toString" | ...
|
||||
>K16 : "0" | "1" | "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
>K16 : number | "0" | "1" | "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
|
||||
type K17 = keyof (Shape | Item); // "name"
|
||||
>K17 : "name"
|
||||
@@ -121,7 +121,7 @@ type K18 = keyof (Shape & Item); // "name" | "width" | "height" | "visible" | "
|
||||
>Item : Item
|
||||
|
||||
type K19 = keyof NumericallyIndexed<Shape> // never
|
||||
>K19 : never
|
||||
>K19 : number
|
||||
>NumericallyIndexed : NumericallyIndexed<T>
|
||||
>Shape : Shape
|
||||
|
||||
@@ -136,7 +136,7 @@ type K20 = KeyOf<Shape>; // "name" | "width" | "height" | "visible"
|
||||
>Shape : Shape
|
||||
|
||||
type K21 = KeyOf<Dictionary<Shape>>; // string
|
||||
>K21 : string
|
||||
>K21 : string | number | symbol
|
||||
>KeyOf : keyof T
|
||||
>Dictionary : Dictionary<T>
|
||||
>Shape : Shape
|
||||
@@ -825,7 +825,7 @@ function f54<T>(obj: T, key: keyof T) {
|
||||
>T : T
|
||||
|
||||
for (let s in obj[key]) {
|
||||
>s : keyof T[keyof T]
|
||||
>s : Extract<keyof T[keyof T], string>
|
||||
>obj[key] : T[keyof T]
|
||||
>obj : T
|
||||
>key : keyof T
|
||||
@@ -850,7 +850,7 @@ function f55<T, K extends keyof T>(obj: T, key: K) {
|
||||
>K : K
|
||||
|
||||
for (let s in obj[key]) {
|
||||
>s : keyof T[K]
|
||||
>s : Extract<keyof T[K], string>
|
||||
>obj[key] : T[K]
|
||||
>obj : T
|
||||
>key : K
|
||||
@@ -873,17 +873,17 @@ function f60<T>(source: T, target: T) {
|
||||
>T : T
|
||||
|
||||
for (let k in source) {
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
>source : T
|
||||
|
||||
target[k] = source[k];
|
||||
>target[k] = source[k] : T[keyof T]
|
||||
>target[k] : T[keyof T]
|
||||
>target[k] = source[k] : T[Extract<keyof T, string>]
|
||||
>target[k] : T[Extract<keyof T, string>]
|
||||
>target : T
|
||||
>k : keyof T
|
||||
>source[k] : T[keyof T]
|
||||
>k : Extract<keyof T, string>
|
||||
>source[k] : T[Extract<keyof T, string>]
|
||||
>source : T
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2295,10 +2295,11 @@ new AnotherSampleClass({});
|
||||
>{} : {}
|
||||
|
||||
// Positive repro from #17166
|
||||
function f3<T, K extends keyof T>(t: T, k: K, tk: T[K]): void {
|
||||
>f3 : <T, K extends keyof T>(t: T, k: K, tk: T[K]) => void
|
||||
function f3<T, K extends Extract<keyof T, string>>(t: T, k: K, tk: T[K]): void {
|
||||
>f3 : <T, K extends Extract<keyof T, string>>(t: T, k: K, tk: T[K]) => void
|
||||
>T : T
|
||||
>K : K
|
||||
>Extract : Extract<T, U>
|
||||
>T : T
|
||||
>t : T
|
||||
>T : T
|
||||
@@ -2309,19 +2310,19 @@ function f3<T, K extends keyof T>(t: T, k: K, tk: T[K]): void {
|
||||
>K : K
|
||||
|
||||
for (let key in t) {
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
>t : T
|
||||
|
||||
key = k // ok, K ==> keyof T
|
||||
>key = k : K
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
>k : K
|
||||
|
||||
t[key] = tk; // ok, T[K] ==> T[keyof T]
|
||||
>t[key] = tk : T[K]
|
||||
>t[key] : T[keyof T]
|
||||
>t[key] : T[Extract<keyof T, string>]
|
||||
>t : T
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
>tk : T[K]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,19 +28,22 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(76,5): error
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(77,5): error TS2322: Type 'keyof T | keyof U' is not assignable to type 'keyof (T | U)'.
|
||||
Type 'keyof T' is not assignable to type 'keyof (T | U)'.
|
||||
Type 'string' is not assignable to type 'keyof (T | U)'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(86,9): error TS2322: Type 'keyof T' is not assignable to type 'K'.
|
||||
Type 'string' is not assignable to type 'K'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(88,9): error TS2322: Type 'T[keyof T]' is not assignable to type 'T[K]'.
|
||||
Type 'keyof T' is not assignable to type 'K'.
|
||||
Type 'string | number | symbol' is not assignable to type 'keyof (T | U)'.
|
||||
Type 'string' is not assignable to type 'keyof (T | U)'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(86,9): error TS2322: Type 'Extract<keyof T, string>' is not assignable to type 'K'.
|
||||
Type 'string & keyof T' is not assignable to type 'K'.
|
||||
Type 'string' is not assignable to type 'K'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(88,9): error TS2322: Type 'T[Extract<keyof T, string>]' is not assignable to type 'T[K]'.
|
||||
Type 'Extract<keyof T, string>' is not assignable to type 'K'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(91,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(94,5): error TS2322: Type 'T[J]' is not assignable to type 'U[J]'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(97,5): error TS2322: Type 'T[K]' is not assignable to type 'T[J]'.
|
||||
Type 'K' is not assignable to type 'J'.
|
||||
Type 'keyof T' is not assignable to type 'J'.
|
||||
Type 'string' is not assignable to type 'J'.
|
||||
Type 'Extract<keyof T, string>' is not assignable to type 'J'.
|
||||
Type 'string & keyof T' is not assignable to type 'J'.
|
||||
Type 'string' is not assignable to type 'J'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(100,5): error TS2322: Type 'T[K]' is not assignable to type 'U[J]'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
|
||||
@@ -178,24 +181,26 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(100,5): error
|
||||
~~
|
||||
!!! error TS2322: Type 'keyof T | keyof U' is not assignable to type 'keyof (T | U)'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'keyof (T | U)'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'keyof (T | U)'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'keyof (T | U)'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'keyof (T | U)'.
|
||||
k2 = k1;
|
||||
}
|
||||
|
||||
// Repro from #17166
|
||||
function f3<T, K extends keyof T, U extends T, J extends K>(
|
||||
function f3<T, K extends Extract<keyof T, string>, U extends T, J extends K>(
|
||||
t: T, k: K, tk: T[K], u: U, j: J, uk: U[K], tj: T[J], uj: U[J]): void {
|
||||
for (let key in t) {
|
||||
key = k // ok, K ==> keyof T
|
||||
k = key // error, keyof T =/=> K
|
||||
~
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'Extract<keyof T, string>' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string & keyof T' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'K'.
|
||||
t[key] = tk; // ok, T[K] ==> T[keyof T]
|
||||
tk = t[key]; // error, T[keyof T] =/=> T[K]
|
||||
~~
|
||||
!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'T[K]'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'T[Extract<keyof T, string>]' is not assignable to type 'T[K]'.
|
||||
!!! error TS2322: Type 'Extract<keyof T, string>' is not assignable to type 'K'.
|
||||
}
|
||||
tk = uk;
|
||||
uk = tk; // error
|
||||
@@ -214,8 +219,9 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(100,5): error
|
||||
~~
|
||||
!!! error TS2322: Type 'T[K]' is not assignable to type 'T[J]'.
|
||||
!!! error TS2322: Type 'K' is not assignable to type 'J'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'J'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'J'.
|
||||
!!! error TS2322: Type 'Extract<keyof T, string>' is not assignable to type 'J'.
|
||||
!!! error TS2322: Type 'string & keyof T' is not assignable to type 'J'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'J'.
|
||||
|
||||
tk = uj;
|
||||
uj = tk; // error
|
||||
|
||||
@@ -80,7 +80,7 @@ function f20<T, U>(k1: keyof (T | U), k2: keyof (T & U), o1: T | U, o2: T & U) {
|
||||
}
|
||||
|
||||
// Repro from #17166
|
||||
function f3<T, K extends keyof T, U extends T, J extends K>(
|
||||
function f3<T, K extends Extract<keyof T, string>, U extends T, J extends K>(
|
||||
t: T, k: K, tk: T[K], u: U, j: J, uk: U[K], tj: T[J], uj: U[J]): void {
|
||||
for (let key in t) {
|
||||
key = k // ok, K ==> keyof T
|
||||
|
||||
@@ -270,18 +270,19 @@ function f20<T, U>(k1: keyof (T | U), k2: keyof (T & U), o1: T | U, o2: T & U) {
|
||||
}
|
||||
|
||||
// Repro from #17166
|
||||
function f3<T, K extends keyof T, U extends T, J extends K>(
|
||||
function f3<T, K extends Extract<keyof T, string>, U extends T, J extends K>(
|
||||
>f3 : Symbol(f3, Decl(keyofAndIndexedAccessErrors.ts, 78, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 81, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 81, 14))
|
||||
>Extract : Symbol(Extract, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 81, 12))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 81, 33))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 81, 50))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 81, 12))
|
||||
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 81, 46))
|
||||
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 81, 63))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 81, 14))
|
||||
|
||||
t: T, k: K, tk: T[K], u: U, j: J, uk: U[K], tj: T[J], uj: U[J]): void {
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 81, 60))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 81, 77))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 81, 12))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 82, 9))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 81, 14))
|
||||
@@ -289,22 +290,22 @@ function f3<T, K extends keyof T, U extends T, J extends K>(
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 81, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 81, 14))
|
||||
>u : Symbol(u, Decl(keyofAndIndexedAccessErrors.ts, 82, 25))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 81, 33))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 81, 50))
|
||||
>j : Symbol(j, Decl(keyofAndIndexedAccessErrors.ts, 82, 31))
|
||||
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 81, 46))
|
||||
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 81, 63))
|
||||
>uk : Symbol(uk, Decl(keyofAndIndexedAccessErrors.ts, 82, 37))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 81, 33))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 81, 50))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 81, 14))
|
||||
>tj : Symbol(tj, Decl(keyofAndIndexedAccessErrors.ts, 82, 47))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 81, 12))
|
||||
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 81, 46))
|
||||
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 81, 63))
|
||||
>uj : Symbol(uj, Decl(keyofAndIndexedAccessErrors.ts, 82, 57))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 81, 33))
|
||||
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 81, 46))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccessErrors.ts, 81, 50))
|
||||
>J : Symbol(J, Decl(keyofAndIndexedAccessErrors.ts, 81, 63))
|
||||
|
||||
for (let key in t) {
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 83, 12))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 81, 60))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 81, 77))
|
||||
|
||||
key = k // ok, K ==> keyof T
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 83, 12))
|
||||
@@ -315,13 +316,13 @@ function f3<T, K extends keyof T, U extends T, J extends K>(
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 83, 12))
|
||||
|
||||
t[key] = tk; // ok, T[K] ==> T[keyof T]
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 81, 60))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 81, 77))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 83, 12))
|
||||
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 82, 15))
|
||||
|
||||
tk = t[key]; // error, T[keyof T] =/=> T[K]
|
||||
>tk : Symbol(tk, Decl(keyofAndIndexedAccessErrors.ts, 82, 15))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 81, 60))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 81, 77))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccessErrors.ts, 83, 12))
|
||||
}
|
||||
tk = uk;
|
||||
|
||||
@@ -22,7 +22,7 @@ type Dictionary<T> = { [x: string]: T };
|
||||
>T : T
|
||||
|
||||
type T00 = keyof K0; // Error
|
||||
>T00 : string
|
||||
>T00 : string | number | symbol
|
||||
>K0 : No type information available!
|
||||
|
||||
type T01 = keyof Object;
|
||||
@@ -30,23 +30,23 @@ type T01 = keyof Object;
|
||||
>Object : Object
|
||||
|
||||
type T02 = keyof keyof Object;
|
||||
>T02 : "length" | "toString" | "valueOf" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr"
|
||||
>T02 : number | "length" | "toString" | "valueOf" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr"
|
||||
>Object : Object
|
||||
|
||||
type T03 = keyof keyof keyof Object;
|
||||
>T03 : "length" | "toString" | "valueOf" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr"
|
||||
>T03 : "toString" | "toLocaleString" | "valueOf"
|
||||
>Object : Object
|
||||
|
||||
type T04 = keyof keyof keyof keyof Object;
|
||||
>T04 : "length" | "toString" | "valueOf" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr"
|
||||
>T04 : number | "length" | "toString" | "valueOf" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr"
|
||||
>Object : Object
|
||||
|
||||
type T05 = keyof keyof keyof keyof keyof Object;
|
||||
>T05 : "length" | "toString" | "valueOf" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr"
|
||||
>T05 : "toString" | "toLocaleString" | "valueOf"
|
||||
>Object : Object
|
||||
|
||||
type T06 = keyof keyof keyof keyof keyof keyof Object;
|
||||
>T06 : "length" | "toString" | "valueOf" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr"
|
||||
>T06 : number | "length" | "toString" | "valueOf" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr"
|
||||
>Object : Object
|
||||
|
||||
type T10 = Shape["name"];
|
||||
@@ -301,10 +301,11 @@ function f20<T, U>(k1: keyof (T | U), k2: keyof (T & U), o1: T | U, o2: T & U) {
|
||||
}
|
||||
|
||||
// Repro from #17166
|
||||
function f3<T, K extends keyof T, U extends T, J extends K>(
|
||||
>f3 : <T, K extends keyof T, U extends T, J extends K>(t: T, k: K, tk: T[K], u: U, j: J, uk: U[K], tj: T[J], uj: U[J]) => void
|
||||
function f3<T, K extends Extract<keyof T, string>, U extends T, J extends K>(
|
||||
>f3 : <T, K extends Extract<keyof T, string>, U extends T, J extends K>(t: T, k: K, tk: T[K], u: U, j: J, uk: U[K], tj: T[J], uj: U[J]) => void
|
||||
>T : T
|
||||
>K : K
|
||||
>Extract : Extract<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
@@ -334,32 +335,32 @@ function f3<T, K extends keyof T, U extends T, J extends K>(
|
||||
>J : J
|
||||
|
||||
for (let key in t) {
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
>t : T
|
||||
|
||||
key = k // ok, K ==> keyof T
|
||||
>key = k : K
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
>k : K
|
||||
|
||||
k = key // error, keyof T =/=> K
|
||||
>k = key : keyof T
|
||||
>k = key : Extract<keyof T, string>
|
||||
>k : K
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
|
||||
t[key] = tk; // ok, T[K] ==> T[keyof T]
|
||||
>t[key] = tk : T[K]
|
||||
>t[key] : T[keyof T]
|
||||
>t[key] : T[Extract<keyof T, string>]
|
||||
>t : T
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
>tk : T[K]
|
||||
|
||||
tk = t[key]; // error, T[keyof T] =/=> T[K]
|
||||
>tk = t[key] : T[keyof T]
|
||||
>tk = t[key] : T[Extract<keyof T, string>]
|
||||
>tk : T[K]
|
||||
>t[key] : T[keyof T]
|
||||
>t[key] : T[Extract<keyof T, string>]
|
||||
>t : T
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
}
|
||||
tk = uk;
|
||||
>tk = uk : U[K]
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
tests/cases/compiler/lateBoundConstraintTypeChecksCorrectly.ts(17,16): error TS2536: Type 'unique symbol' cannot be used to index type 'T'.
|
||||
tests/cases/compiler/lateBoundConstraintTypeChecksCorrectly.ts(18,17): error TS2536: Type 'unique symbol' cannot be used to index type 'T'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/lateBoundConstraintTypeChecksCorrectly.ts (2 errors) ====
|
||||
declare const fooProp: unique symbol;
|
||||
declare const barProp: unique symbol;
|
||||
|
||||
type BothProps = typeof fooProp | typeof barProp;
|
||||
|
||||
export interface Foo<T> {
|
||||
[fooProp]: T;
|
||||
[barProp]: string;
|
||||
}
|
||||
|
||||
function f<T extends Foo<number>>(x: T) {
|
||||
const abc = x[fooProp]; // expected: 'T[typeof fooProp]'
|
||||
|
||||
/**
|
||||
* Expected: no error
|
||||
*/
|
||||
const def: T[typeof fooProp] = x[fooProp];
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2536: Type 'unique symbol' cannot be used to index type 'T'.
|
||||
const def2: T[typeof barProp] = x[barProp];
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2536: Type 'unique symbol' cannot be used to index type 'T'.
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(19,20): error TS2313: Type parameter 'P' has a circular constraint.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(20,20): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(21,20): error TS2322: Type 'Date' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(22,19): error TS2344: Type 'Date' does not satisfy the constraint 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(21,20): error TS2322: Type 'Date' is not assignable to type 'string | number | symbol'.
|
||||
Type 'Date' is not assignable to type 'symbol'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(22,19): error TS2344: Type 'Date' does not satisfy the constraint 'string | number | symbol'.
|
||||
Type 'Date' is not assignable to type 'symbol'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(25,24): error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(26,24): error TS2344: Type '"name" | "foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
Type '"foo"' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
@@ -45,11 +46,12 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(129,5): error TS2322: T
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(130,5): error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'string' is not assignable to type 'number | undefined'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,16): error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,16): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
|
||||
Type 'T' is not assignable to type 'symbol'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536: Type 'P' cannot be used to index type 'T'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (26 errors) ====
|
||||
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (25 errors) ====
|
||||
interface Shape {
|
||||
name: string;
|
||||
width: number;
|
||||
@@ -72,14 +74,14 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536:
|
||||
~
|
||||
!!! error TS2313: Type parameter 'P' has a circular constraint.
|
||||
type T01 = { [P in number]: string }; // Error
|
||||
~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
type T02 = { [P in Date]: number }; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'Date' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'Date' is not assignable to type 'string | number | symbol'.
|
||||
!!! error TS2322: Type 'Date' is not assignable to type 'symbol'.
|
||||
type T03 = Record<Date, number>; // Error
|
||||
~~~~
|
||||
!!! error TS2344: Type 'Date' does not satisfy the constraint 'string'.
|
||||
!!! error TS2344: Type 'Date' does not satisfy the constraint 'string | number | symbol'.
|
||||
!!! error TS2344: Type 'Date' is not assignable to type 'symbol'.
|
||||
|
||||
type T10 = Pick<Shape, "name">;
|
||||
type T11 = Pick<Shape, "foo">; // Error
|
||||
@@ -258,7 +260,8 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536:
|
||||
pf: {[P in F]?: T[P]},
|
||||
pt: {[P in T]?: T[P]}, // note: should be in keyof T
|
||||
~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'symbol'.
|
||||
~~~~
|
||||
!!! error TS2536: Type 'P' cannot be used to index type 'T'.
|
||||
};
|
||||
|
||||
@@ -373,17 +373,17 @@ function setState<T, K extends keyof T>(obj: T, props: Pick<T, K>) {
|
||||
>K : K
|
||||
|
||||
for (let k in props) {
|
||||
>k : K
|
||||
>k : Extract<K, string>
|
||||
>props : Pick<T, K>
|
||||
|
||||
obj[k] = props[k];
|
||||
>obj[k] = props[k] : Pick<T, K>[K]
|
||||
>obj[k] : T[K]
|
||||
>obj[k] = props[k] : Pick<T, K>[Extract<K, string>]
|
||||
>obj[k] : T[Extract<K, string>]
|
||||
>obj : T
|
||||
>k : K
|
||||
>props[k] : Pick<T, K>[K]
|
||||
>k : Extract<K, string>
|
||||
>props[k] : Pick<T, K>[Extract<K, string>]
|
||||
>props : Pick<T, K>
|
||||
>k : K
|
||||
>k : Extract<K, string>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,19 +468,19 @@ class C<T> {
|
||||
>K : K
|
||||
|
||||
for (let k in props) {
|
||||
>k : K
|
||||
>k : Extract<K, string>
|
||||
>props : Pick<T, K>
|
||||
|
||||
this.state[k] = props[k];
|
||||
>this.state[k] = props[k] : Pick<T, K>[K]
|
||||
>this.state[k] : T[K]
|
||||
>this.state[k] = props[k] : Pick<T, K>[Extract<K, string>]
|
||||
>this.state[k] : T[Extract<K, string>]
|
||||
>this.state : T
|
||||
>this : this
|
||||
>state : T
|
||||
>k : K
|
||||
>props[k] : Pick<T, K>[K]
|
||||
>k : Extract<K, string>
|
||||
>props[k] : Pick<T, K>[Extract<K, string>]
|
||||
>props : Pick<T, K>
|
||||
>k : K
|
||||
>k : Extract<K, string>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,16 +43,20 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(143,5): error TS
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(148,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'.
|
||||
Type 'keyof U' is not assignable to type 'keyof T'.
|
||||
Type 'string' is not assignable to type 'keyof T'.
|
||||
Type 'string | number | symbol' is not assignable to type 'keyof T'.
|
||||
Type 'string' is not assignable to type 'keyof T'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(153,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'.
|
||||
Type 'keyof T' is not assignable to type 'K'.
|
||||
Type 'string' is not assignable to type 'K'.
|
||||
Type 'string | number | symbol' is not assignable to type 'K'.
|
||||
Type 'string' is not assignable to type 'K'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(158,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'.
|
||||
Type 'keyof U' is not assignable to type 'K'.
|
||||
Type 'string' is not assignable to type 'K'.
|
||||
Type 'string | number | symbol' is not assignable to type 'K'.
|
||||
Type 'string' is not assignable to type 'K'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(163,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'.
|
||||
Type 'keyof T' is not assignable to type 'K'.
|
||||
Type 'string' is not assignable to type 'K'.
|
||||
Type 'string | number | symbol' is not assignable to type 'K'.
|
||||
Type 'string' is not assignable to type 'K'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'.
|
||||
Type 'T[P]' is not assignable to type 'U[P]'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
@@ -276,7 +280,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
|
||||
~
|
||||
!!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'.
|
||||
!!! error TS2322: Type 'keyof U' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'keyof T'.
|
||||
}
|
||||
|
||||
function f73<T, K extends keyof T>(x: { [P in K]: T[P] }, y: { [P in keyof T]: T[P] }) {
|
||||
@@ -285,7 +290,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
|
||||
~
|
||||
!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'K'.
|
||||
}
|
||||
|
||||
function f74<T, U extends T, K extends keyof T>(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) {
|
||||
@@ -294,7 +300,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
|
||||
~
|
||||
!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'.
|
||||
!!! error TS2322: Type 'keyof U' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'K'.
|
||||
}
|
||||
|
||||
function f75<T, U extends T, K extends keyof T>(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) {
|
||||
@@ -303,7 +310,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS
|
||||
~
|
||||
!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'.
|
||||
!!! error TS2322: Type 'keyof T' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'K'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'K'.
|
||||
}
|
||||
|
||||
function f76<T, U extends T, K extends keyof T>(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) {
|
||||
|
||||
@@ -11,7 +11,7 @@ type ItemMap<T> = { [P in keyof T]: Item };
|
||||
>Item : Item
|
||||
|
||||
declare let x0: keyof any;
|
||||
>x0 : string
|
||||
>x0 : string | number | symbol
|
||||
|
||||
declare let x1: { [P in any]: Item };
|
||||
>x1 : { [x: string]: Item; }
|
||||
|
||||
@@ -40,19 +40,19 @@ function boxify<T>(obj: T): Boxified<T> {
|
||||
>T : T
|
||||
|
||||
for (let k in obj) {
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
>obj : T
|
||||
|
||||
result[k] = { value: obj[k] };
|
||||
>result[k] = { value: obj[k] } : { value: T[keyof T]; }
|
||||
>result[k] : Boxified<T>[keyof T]
|
||||
>result[k] = { value: obj[k] } : { value: T[Extract<keyof T, string>]; }
|
||||
>result[k] : Boxified<T>[Extract<keyof T, string>]
|
||||
>result : Boxified<T>
|
||||
>k : keyof T
|
||||
>{ value: obj[k] } : { value: T[keyof T]; }
|
||||
>value : T[keyof T]
|
||||
>obj[k] : T[keyof T]
|
||||
>k : Extract<keyof T, string>
|
||||
>{ value: obj[k] } : { value: T[Extract<keyof T, string>]; }
|
||||
>value : T[Extract<keyof T, string>]
|
||||
>obj[k] : T[Extract<keyof T, string>]
|
||||
>obj : T
|
||||
>k : keyof T
|
||||
>k : Extract<keyof T, string>
|
||||
}
|
||||
return result;
|
||||
>result : Boxified<T>
|
||||
|
||||
@@ -6,7 +6,7 @@ type T02 = string & never;
|
||||
>T02 : never
|
||||
|
||||
type T03 = string | number | never;
|
||||
>T03 : string | number
|
||||
>T03 : T03
|
||||
|
||||
type T04 = string & number & never;
|
||||
>T04 : never
|
||||
|
||||
@@ -6,7 +6,7 @@ tests/cases/compiler/recursiveTypeRelations.ts(27,61): error TS2304: Cannot find
|
||||
==== tests/cases/compiler/recursiveTypeRelations.ts (3 errors) ====
|
||||
// Repro from #14896
|
||||
|
||||
type Attributes<Keys extends string> = {
|
||||
type Attributes<Keys extends keyof any> = {
|
||||
[Key in Keys]: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//// [recursiveTypeRelations.ts]
|
||||
// Repro from #14896
|
||||
|
||||
type Attributes<Keys extends string> = {
|
||||
type Attributes<Keys extends keyof any> = {
|
||||
[Key in Keys]: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
=== tests/cases/compiler/recursiveTypeRelations.ts ===
|
||||
// Repro from #14896
|
||||
|
||||
type Attributes<Keys extends string> = {
|
||||
type Attributes<Keys extends keyof any> = {
|
||||
>Attributes : Symbol(Attributes, Decl(recursiveTypeRelations.ts, 0, 0))
|
||||
>Keys : Symbol(Keys, Decl(recursiveTypeRelations.ts, 2, 16))
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
=== tests/cases/compiler/recursiveTypeRelations.ts ===
|
||||
// Repro from #14896
|
||||
|
||||
type Attributes<Keys extends string> = {
|
||||
type Attributes<Keys extends keyof any> = {
|
||||
>Attributes : { [Key in Keys]: string; }
|
||||
>Keys : Keys
|
||||
|
||||
|
||||
@@ -80,19 +80,19 @@ function fun<T>(item: { [P in keyof T]: T[P] }) {
|
||||
>[] : never[]
|
||||
|
||||
for (const key in item) {
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
>item : { [P in keyof T]: T[P]; }
|
||||
|
||||
const value = item[key];
|
||||
>value : { [P in keyof T]: T[P]; }[keyof T]
|
||||
>item[key] : { [P in keyof T]: T[P]; }[keyof T]
|
||||
>value : { [P in keyof T]: T[P]; }[Extract<keyof T, string>]
|
||||
>item[key] : { [P in keyof T]: T[P]; }[Extract<keyof T, string>]
|
||||
>item : { [P in keyof T]: T[P]; }
|
||||
>key : keyof T
|
||||
>key : Extract<keyof T, string>
|
||||
|
||||
if (typeof value === "string") {
|
||||
>typeof value === "string" : boolean
|
||||
>typeof value : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>value : { [P in keyof T]: T[P]; }[keyof T]
|
||||
>value : { [P in keyof T]: T[P]; }[Extract<keyof T, string>]
|
||||
>"string" : "string"
|
||||
|
||||
strings.push(value);
|
||||
@@ -100,7 +100,7 @@ function fun<T>(item: { [P in keyof T]: T[P] }) {
|
||||
>strings.push : (...items: string[]) => number
|
||||
>strings : string[]
|
||||
>push : (...items: string[]) => number
|
||||
>value : { [P in keyof T]: T[P]; }[keyof T] & string
|
||||
>value : { [P in keyof T]: T[P]; }[Extract<keyof T, string>] & string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user