-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
Bug Report
🔎 Search Terms
"quick fix mapped type" "add missing properties mapped type"
🕗 Version & Regression Information
- Based on changing version with the playground below,
4.5+whenquick fixwas added - Behavior is still present on
Nightly
⏯ Playground Link
Playground link with relevant code
💻 Code
See playground link for full example.
interface BasicType{
numb: number,
name: string,
}
interface OtherType{
bool: boolean
}
interface MappingType{
basic: BasicType,
other: OtherType
}
function test2<T extends keyof MappingType>(type: T, obj: MappingType[T]):string{
return "arbitrary"
}
//TS2345, understands `obj` is of type `BasicType`, `quick fix` not available
const val2 = test2("basic",{});🙁 Actual behavior
-
TS-2345 for both lines in the playground.
-
quick fixis available for function call using type directly.
quick fixis not available for function call using mapped type even though TS does understand its type.
Error message is the same for both:
Argument of type '{}' is not assignable to parameter of type 'BasicType'.
Type '{}' is missing the following properties from type 'BasicType': numb, name(2345)
🙂 Expected behavior
- TS-2345 for both lines in the playground.
quick fixfor TS-2345 to "add missing properties" to be available on both empty function call parameters.
Metadata
Metadata
Assignees
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript

