-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
π Search Terms
conditional method arrow function
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ
β― Playground Link
π» Code
type Map<T> = {
readonly [P in keyof T]: T[P] extends boolean ? "boolean": "other"
}
export function buildCommand<F extends Record<string, unknown>>(builderArgs: {
func: (p: F) => void
params: Map<NoInfer<F>>
}) {
}
type Foo = { foo: boolean };
// Function expression does not work
buildCommand({
func: function (p: Foo) { },
params: {
foo: "boolean"
}
})
// Methods don't work
buildCommand({
func(p: Foo) { },
params: {
foo: "boolean"
}
})
// Arrow function works
buildCommand({
func: (p: Foo) => { },
params: {
foo: "boolean"
}
})π Actual behavior
For the first two calls we get an error while the third one is successful
π Expected behavior
All three calls should be successful
Additional information about the issue
Removing the constraint from F (Playground Link) or changing it to F extends Record<keyof F, unknown> (Playground Link) will remove the error.
Metadata
Metadata
Assignees
Labels
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases