-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
Bug Report
π Search Terms
inference generic extends record
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about "extends"
β― Playground Link
Playground link with relevant code
π» Code
type TestType<Keys extends string> = string extends Keys ? Record<Keys, string> : Record<Keys, string>
function inferHelper<Keys extends string>(data: TestType<Keys>) {
return data;
}
export const a = inferHelper({
// key1 is inferred to be value1 here
key1: "value1"
})π Actual behavior
ts2345
Argument of type '{ key1: string; }' is not assignable to parameter of type 'Record<"value1", string>'.
Object literal may only specify known properties, and 'key1' does not exist in type 'Record<"value1", string>'
π Expected behavior
no error, and the record is inferred as Record<"key1", string>
fatcerberus, Lucaz86 and RyanCavanaugh
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone