Skip to content

Ignore the keyofStringsOnly setting so we can see who depends on it and how #50852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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 };
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/keyofDoesntContainSymbols.types
Original file line number Diff line number Diff line change
Expand Up @@ -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 : <T extends object, K extends keyof T>(obj: T, key: K, value: T[K]) => T[K]
>obj : { num: number; str: string; 0: 0; [sym]: symbol; }
>sym : unique symbol
Expand All @@ -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 : <T extends object, K extends keyof T>(obj: T, key: K, value: T[K]) => T[K]
>obj : { num: number; str: string; 0: 0; [sym]: symbol; }
>num : 0
Expand All @@ -77,14 +77,14 @@ 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"
type Values<T> = T[keyof T];
>Values : Values<T>

type ValuesOfObj = Values<typeof obj>;
>ValuesOfObj : string | number
>ValuesOfObj : string | number | symbol
>obj : { num: number; str: string; 0: 0; [sym]: symbol; }