🔎 Search Terms
toString mapped type
🕗 Version & Regression Information
- This changed between versions 4.6 and 4.7
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-dev.20240110#code/C4TwDgpgBAsghmMIA8AVKEAewIDsAmAzlAK64DWuA9gO64DaAugHxQC8UA3lPQNJQBLXFHIQQVAGZR0cYr0YAuaX0ZQAvgG4AsAChQkKADkqwAIIAnc3BDtYCJMlwkAtgCMI5ps207d+CADGADZw5tASZAHAAlTC+FQWViAAysAkEhIAFJhKZJS0DIwAlEoAblQC+D7+waHQAbGEwFA5RiaJ1tUJltap6VmYRRpAA
💻 Code
typeMappy<Textendsunknown[]>={[KinkeyofTasK]: T[K]};typeNotArray=Mappy<number[]>;declarefunctiondoArrayStuff(x: unknown[]): void;declareconstx: NotArray;doArrayStuff(x);// Error🙁 Actual behavior
Error on doArrayStuff(x):
Argument of type 'Mappy<number[]>' is not assignable to parameter of type 'unknown[]'.
Types of property 'toString' are incompatible.
Type 'number' is not assignable to type '() => string'
🙂 Expected behavior
No error, type of x's toString is () => string.
Additional information about the issue
No response
🔎 Search Terms
toString mapped type
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-dev.20240110#code/C4TwDgpgBAsghmMIA8AVKEAewIDsAmAzlAK64DWuA9gO64DaAugHxQC8UA3lPQNJQBLXFHIQQVAGZR0cYr0YAuaX0ZQAvgG4AsAChQkKADkqwAIIAnc3BDtYCJMlwkAtgCMI5ps207d+CADGADZw5tASZAHAAlTC+FQWViAAysAkEhIAFJhKZJS0DIwAlEoAblQC+D7+waHQAbGEwFA5RiaJ1tUJltap6VmYRRpAA
💻 Code
🙁 Actual behavior
Error on
doArrayStuff(x):Argument of type 'Mappy<number[]>' is not assignable to parameter of type 'unknown[]'.
Types of property 'toString' are incompatible.
Type 'number' is not assignable to type '() => string'
🙂 Expected behavior
No error, type of
x'stoStringis() => string.Additional information about the issue
No response