-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 3.7-beta
Search Terms: inference, generic functions
Code
export function foo<T, K>(props: {
seed: T;
producer: (x: T) => K;
consumer: (data: K) => void;
}) {
//
}
foo({
seed: "foo",
producer: (seed) => {
// type of `seed` is string
return seed;
},
consumer: (data) => {
// type of `data` is unknown
}
})
Expected behavior: TypeScript infers K
to a string
, so the type of data
is string
.
Actual behavior: data
variable is unknown
.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created