We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript Version: 3.7-beta
Search Terms:
Code
type RefSelf<Input extends Record<string, (...args: any[]) => unknown>> = { [k in keyof Input]: () => ReturnType<Input[k]> } declare function calculate < Input extends Record<string, (self: RefSelf<Input>) => unknown>, >(input: Input): RefSelf<Input> const { fourtyTwo, fourtyTwo2 } = calculate({ fourtyTwo: () => 42, // (parameter) self: RefSelf<{fourtyTwo: unknown; fourtyTwo2: unknown;}> // (property) fourtyTwo: () => any fourtyTwo2: (self) => self.fourtyTwo(), })
Expected behavior:
output of the calculate be inferred as { fourtyTwo: () => number, fourtyTwo2: () => number }
{ fourtyTwo: () => number, fourtyTwo2: () => number }
self be inferred as RefSelf<{ fourtyTwo: unknown; fourtyTwo2: unknown; }>
self
RefSelf<{ fourtyTwo: unknown; fourtyTwo2: unknown; }>
Actual behavior:
output of the calculate be inferred as { fourtyTwo: () => number, fourtyTwo2: () => any }
{ fourtyTwo: () => number, fourtyTwo2: () => any }
self be inferred as RefSelf<{ fourtyTwo: () => number; fourtyTwo2: () => number; }>
RefSelf<{ fourtyTwo: () => number; fourtyTwo2: () => number; }>
Playground Link: http://www.typescriptlang.org/play/#code/C4TwDgpgBAShBmBlCAbeAeAkgOzAV2CggA9gJsATAZ1ggGMB7AJwvSuCYEtsBzAGigAKAHSiAhkx5UAXFDHYQAbQC6ASigBeAHxQ82ANbYGAd2xadGqAG8AUFCiL9UblH0QQDeFBz5gy2YLq2rTAeEzYACrgEFi4BI7KWjYAvjY2FPQoEtDwenTAnAzYUHRiKHR4WWRQ6HbecYQkZJQ0cIwsbBzc-EJUqPCycEj9sb5aQTp6hiZmfDZagty+sj4EqoMIyGijBEk2jNjs1lDwDGGgEcYMAqfnIJcMAExQyZolZRVVEIK29rdMFyuAQmUAALI85vYAPRQoRgCRiAC2EDITHUfTQG2G2ys-0BDFkUyMpgA3CczgD7ldHoSDMTsCTkklobDBGAmAxIJT1HiqQShCD5CA6ryHjTev0QRj4MJRVdAnNkqogA
Related Issues:
The text was updated successfully, but these errors were encountered:
We'd need multiple rounds of inference to be able to handle this situation correctly. Ref. #30134
Sorry, something went wrong.
No branches or pull requests
TypeScript Version: 3.7-beta
Search Terms:
Code
Expected behavior:
output of the calculate be inferred as
{ fourtyTwo: () => number, fourtyTwo2: () => number }
self
be inferred asRefSelf<{ fourtyTwo: unknown; fourtyTwo2: unknown; }>
Actual behavior:
output of the calculate be inferred as
{ fourtyTwo: () => number, fourtyTwo2: () => any }
self
be inferred asRefSelf<{ fourtyTwo: () => number; fourtyTwo2: () => number; }>
Playground Link: http://www.typescriptlang.org/play/#code/C4TwDgpgBAShBmBlCAbeAeAkgOzAV2CggA9gJsATAZ1ggGMB7AJwvSuCYEtsBzAGigAKAHSiAhkx5UAXFDHYQAbQC6ASigBeAHxQ82ANbYGAd2xadGqAG8AUFCiL9UblH0QQDeFBz5gy2YLq2rTAeEzYACrgEFi4BI7KWjYAvjY2FPQoEtDwenTAnAzYUHRiKHR4WWRQ6HbecYQkZJQ0cIwsbBzc-EJUqPCycEj9sb5aQTp6hiZmfDZagty+sj4EqoMIyGijBEk2jNjs1lDwDGGgEcYMAqfnIJcMAExQyZolZRVVEIK29rdMFyuAQmUAALI85vYAPRQoRgCRiAC2EDITHUfTQG2G2ys-0BDFkUyMpgA3CczgD7ldHoSDMTsCTkklobDBGAmAxIJT1HiqQShCD5CA6ryHjTev0QRj4MJRVdAnNkqogA
Related Issues:
The text was updated successfully, but these errors were encountered: