From 2f2b500f4e3a11b83c95492077c957ebcd887903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 30 Nov 2024 16:21:32 +0100 Subject: [PATCH] add extra test case --- .../keyRemappingKeyofResult(strict=false).errors.txt | 1 + .../reference/keyRemappingKeyofResult(strict=false).js | 2 ++ .../reference/keyRemappingKeyofResult(strict=false).symbols | 4 ++++ .../reference/keyRemappingKeyofResult(strict=false).types | 6 ++++++ .../keyRemappingKeyofResult(strict=true).errors.txt | 1 + .../reference/keyRemappingKeyofResult(strict=true).js | 2 ++ .../reference/keyRemappingKeyofResult(strict=true).symbols | 4 ++++ .../reference/keyRemappingKeyofResult(strict=true).types | 6 ++++++ tests/cases/compiler/keyRemappingKeyofResult.ts | 1 + 9 files changed, 27 insertions(+) diff --git a/tests/baselines/reference/keyRemappingKeyofResult(strict=false).errors.txt b/tests/baselines/reference/keyRemappingKeyofResult(strict=false).errors.txt index 5f69889fa7e76..2766d32ccf3d3 100644 --- a/tests/baselines/reference/keyRemappingKeyofResult(strict=false).errors.txt +++ b/tests/baselines/reference/keyRemappingKeyofResult(strict=false).errors.txt @@ -99,6 +99,7 @@ keyRemappingKeyofResult.ts(90,3): error TS2322: Type 'string' is not assignable ~ !!! error TS2322: Type 'string' is not assignable to type 'keyof { [P in keyof T as T[P] extends string ? P : never]: any; }'. !!! error TS2322: Type 'string' is not assignable to type 'T[P] extends string ? P : never'. + const f: string = z; // error } export {}; diff --git a/tests/baselines/reference/keyRemappingKeyofResult(strict=false).js b/tests/baselines/reference/keyRemappingKeyofResult(strict=false).js index 7169b9e7ef77d..8700ad6f94a09 100644 --- a/tests/baselines/reference/keyRemappingKeyofResult(strict=false).js +++ b/tests/baselines/reference/keyRemappingKeyofResult(strict=false).js @@ -91,6 +91,7 @@ type StringKeys2 = keyof { function h(z: StringKeys2) { z = "foo"; // error + const f: string = z; // error } export {}; @@ -127,5 +128,6 @@ function test_57827(z) { } function h(z) { z = "foo"; // error + const f = z; // error } export {}; diff --git a/tests/baselines/reference/keyRemappingKeyofResult(strict=false).symbols b/tests/baselines/reference/keyRemappingKeyofResult(strict=false).symbols index 8e49e52eab8a4..0f4c51cb6a865 100644 --- a/tests/baselines/reference/keyRemappingKeyofResult(strict=false).symbols +++ b/tests/baselines/reference/keyRemappingKeyofResult(strict=false).symbols @@ -247,6 +247,10 @@ function h(z: StringKeys2) { >T : Symbol(T, Decl(keyRemappingKeyofResult.ts, 88, 11)) z = "foo"; // error +>z : Symbol(z, Decl(keyRemappingKeyofResult.ts, 88, 14)) + + const f: string = z; // error +>f : Symbol(f, Decl(keyRemappingKeyofResult.ts, 90, 7)) >z : Symbol(z, Decl(keyRemappingKeyofResult.ts, 88, 14)) } diff --git a/tests/baselines/reference/keyRemappingKeyofResult(strict=false).types b/tests/baselines/reference/keyRemappingKeyofResult(strict=false).types index 9dd85908b9966..b8ae897ed6c63 100644 --- a/tests/baselines/reference/keyRemappingKeyofResult(strict=false).types +++ b/tests/baselines/reference/keyRemappingKeyofResult(strict=false).types @@ -298,6 +298,12 @@ function h(z: StringKeys2) { > : ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >"foo" : "foo" > : ^^^^^ + + const f: string = z; // error +>f : string +> : ^^^^^^ +>z : string +> : ^^^^^^ } export {}; diff --git a/tests/baselines/reference/keyRemappingKeyofResult(strict=true).errors.txt b/tests/baselines/reference/keyRemappingKeyofResult(strict=true).errors.txt index 5f69889fa7e76..2766d32ccf3d3 100644 --- a/tests/baselines/reference/keyRemappingKeyofResult(strict=true).errors.txt +++ b/tests/baselines/reference/keyRemappingKeyofResult(strict=true).errors.txt @@ -99,6 +99,7 @@ keyRemappingKeyofResult.ts(90,3): error TS2322: Type 'string' is not assignable ~ !!! error TS2322: Type 'string' is not assignable to type 'keyof { [P in keyof T as T[P] extends string ? P : never]: any; }'. !!! error TS2322: Type 'string' is not assignable to type 'T[P] extends string ? P : never'. + const f: string = z; // error } export {}; diff --git a/tests/baselines/reference/keyRemappingKeyofResult(strict=true).js b/tests/baselines/reference/keyRemappingKeyofResult(strict=true).js index 7169b9e7ef77d..8700ad6f94a09 100644 --- a/tests/baselines/reference/keyRemappingKeyofResult(strict=true).js +++ b/tests/baselines/reference/keyRemappingKeyofResult(strict=true).js @@ -91,6 +91,7 @@ type StringKeys2 = keyof { function h(z: StringKeys2) { z = "foo"; // error + const f: string = z; // error } export {}; @@ -127,5 +128,6 @@ function test_57827(z) { } function h(z) { z = "foo"; // error + const f = z; // error } export {}; diff --git a/tests/baselines/reference/keyRemappingKeyofResult(strict=true).symbols b/tests/baselines/reference/keyRemappingKeyofResult(strict=true).symbols index 8e49e52eab8a4..0f4c51cb6a865 100644 --- a/tests/baselines/reference/keyRemappingKeyofResult(strict=true).symbols +++ b/tests/baselines/reference/keyRemappingKeyofResult(strict=true).symbols @@ -247,6 +247,10 @@ function h(z: StringKeys2) { >T : Symbol(T, Decl(keyRemappingKeyofResult.ts, 88, 11)) z = "foo"; // error +>z : Symbol(z, Decl(keyRemappingKeyofResult.ts, 88, 14)) + + const f: string = z; // error +>f : Symbol(f, Decl(keyRemappingKeyofResult.ts, 90, 7)) >z : Symbol(z, Decl(keyRemappingKeyofResult.ts, 88, 14)) } diff --git a/tests/baselines/reference/keyRemappingKeyofResult(strict=true).types b/tests/baselines/reference/keyRemappingKeyofResult(strict=true).types index 9dd85908b9966..b8ae897ed6c63 100644 --- a/tests/baselines/reference/keyRemappingKeyofResult(strict=true).types +++ b/tests/baselines/reference/keyRemappingKeyofResult(strict=true).types @@ -298,6 +298,12 @@ function h(z: StringKeys2) { > : ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >"foo" : "foo" > : ^^^^^ + + const f: string = z; // error +>f : string +> : ^^^^^^ +>z : string +> : ^^^^^^ } export {}; diff --git a/tests/cases/compiler/keyRemappingKeyofResult.ts b/tests/cases/compiler/keyRemappingKeyofResult.ts index 89f14004660ef..2cec329384b29 100644 --- a/tests/cases/compiler/keyRemappingKeyofResult.ts +++ b/tests/cases/compiler/keyRemappingKeyofResult.ts @@ -90,6 +90,7 @@ type StringKeys2 = keyof { function h(z: StringKeys2) { z = "foo"; // error + const f: string = z; // ok } export {};