Closed
Description
Bug Report
π Search Terms
keyof generic template literal type symbol
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about generics and assignability
β― Playground Link
Playground link with relevant code
π» Code
type KeyGet<T> = `get${keyof T}`;
π Actual behavior
Notice the fourth Type 'keyof T'
line onward. Seems unnecesary?
Type 'keyof T' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
Type 'string | number | symbol' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
Type 'symbol' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
Type 'keyof T' is not assignable to type 'number'.
Type 'string | number | symbol' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
π Expected behavior
Type 'keyof T' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
Type 'string | number | symbol' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
Type 'symbol' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
Note that if you replace keyof T
with string | number | symbol
, the error message is the expected behavior. [playground link with replacement]
type KeyGet<T> = `get${string | number | symbol}`;
Type 'string | number | symbol' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
Type 'symbol' is not assignable to type 'string | number | bigint | boolean | null | undefined'.