-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
🔎 Search Terms
key remapping, error message, 2345
🕗 Version & Regression Information
- This is the behavior in every version I tried since key remapping was introduced in TS4.1; I don't see relevant FAQ entries
⏯ Playground Link
Playground link with relevant code
💻 Code
function foo<T extends { [K in keyof T as `${Extract<K, string>}Oops`]: T[K] }>(x: T) { }
const x = { prop: 123 };
foo(x); // error!
// ~ <-- Argument of type '{ prop: number; }' is not assignable to parameter of type '{ propOops: number; }'.
// Property 'prop' is missing in type '{ prop: number; }' but required in type '{ propOops: number; }'. (2345) 🙁 Actual behavior
The last line of the error message says that the property prop is missing in the type { prop: number }, but it's not.
🙂 Expected behavior
The error should probably say
Property 'propOops' is missing in type '{ prop: number; }' but required in type '{ propOops: number; }'.
I guess the error message is using the original key when it should be using the remapped key? 🤷♂️
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue