diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f992dd0ea458f..f56eb76c7b8a4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -366,7 +366,7 @@ namespace ts { const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny"); const noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis"); const useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); - const keyofStringsOnly = !!compilerOptions.keyofStringsOnly; + const keyofStringsOnly = false; const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral; const exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; diff --git a/tests/baselines/reference/keyofDoesntContainSymbols.errors.txt b/tests/baselines/reference/keyofDoesntContainSymbols.errors.txt index 42a2d373be64e..dfe79282740f0 100644 --- a/tests/baselines/reference/keyofDoesntContainSymbols.errors.txt +++ b/tests/baselines/reference/keyofDoesntContainSymbols.errors.txt @@ -1,9 +1,7 @@ tests/cases/compiler/keyofDoesntContainSymbols.ts(11,30): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/compiler/keyofDoesntContainSymbols.ts(14,23): error TS2345: Argument of type 'unique symbol' is not assignable to parameter of type '"str" | "num"'. -tests/cases/compiler/keyofDoesntContainSymbols.ts(17,23): error TS2345: Argument of type '0' is not assignable to parameter of type '"str" | "num"'. -==== tests/cases/compiler/keyofDoesntContainSymbols.ts (3 errors) ==== +==== tests/cases/compiler/keyofDoesntContainSymbols.ts (1 errors) ==== const sym = Symbol(); const num = 0; const obj = { num: 0, str: 's', [num]: num as 0, [sym]: sym }; @@ -20,13 +18,9 @@ tests/cases/compiler/keyofDoesntContainSymbols.ts(17,23): error TS2345: Argument // Expect type error // Argument of type '""' is not assignable to parameter of type 'number'. const valC = set(obj, sym, sym); - ~~~ -!!! error TS2345: Argument of type 'unique symbol' is not assignable to parameter of type '"str" | "num"'. // Expect type error // Argument of type 'unique symbol' is not assignable to parameter of type "str" | "num" const valD = set(obj, num, num); - ~~~ -!!! error TS2345: Argument of type '0' is not assignable to parameter of type '"str" | "num"'. // Expect type error // Argument of type '0' is not assignable to parameter of type "str" | "num" type KeyofObj = keyof typeof obj; diff --git a/tests/baselines/reference/keyofDoesntContainSymbols.types b/tests/baselines/reference/keyofDoesntContainSymbols.types index 5971064fa36c5..df6269ebdae7e 100644 --- a/tests/baselines/reference/keyofDoesntContainSymbols.types +++ b/tests/baselines/reference/keyofDoesntContainSymbols.types @@ -57,8 +57,8 @@ const valB = set(obj, 'num', ''); // Expect type error // Argument of type '""' is not assignable to parameter of type 'number'. const valC = set(obj, sym, sym); ->valC : string | number ->set(obj, sym, sym) : string | number +>valC : symbol +>set(obj, sym, sym) : symbol >set : (obj: T, key: K, value: T[K]) => T[K] >obj : { num: number; str: string; 0: 0; [sym]: symbol; } >sym : unique symbol @@ -67,8 +67,8 @@ const valC = set(obj, sym, sym); // Expect type error // Argument of type 'unique symbol' is not assignable to parameter of type "str" | "num" const valD = set(obj, num, num); ->valD : string | number ->set(obj, num, num) : string | number +>valD : 0 +>set(obj, num, num) : 0 >set : (obj: T, key: K, value: T[K]) => T[K] >obj : { num: number; str: string; 0: 0; [sym]: symbol; } >num : 0 @@ -77,7 +77,7 @@ const valD = set(obj, num, num); // Expect type error // Argument of type '0' is not assignable to parameter of type "str" | "num" type KeyofObj = keyof typeof obj; ->KeyofObj : "str" | "num" +>KeyofObj : unique symbol | 0 | "str" | "num" >obj : { num: number; str: string; 0: 0; [sym]: symbol; } // "str" | "num" @@ -85,6 +85,6 @@ type Values = T[keyof T]; >Values : Values type ValuesOfObj = Values; ->ValuesOfObj : string | number +>ValuesOfObj : string | number | symbol >obj : { num: number; str: string; 0: 0; [sym]: symbol; }