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: 4.0.5
Search Terms:
infer, object literals, interdependencies
Code
type Selector<S> = (state: S) => any export interface Reducer<T = any> { (state: T | undefined, action: any): T } type UnboxState<R extends Reducer> = R extends Reducer<infer U> ? U : never declare function example<R extends Reducer, S extends Selector<UnboxState<R>>>(r: R, s: S) : void example( (state, action) => ({ name: 'Gio Va' }), state => 23 ) declare function example2<R extends Reducer, S extends Selector<UnboxState<R>>>(x: { r: R, s: S }) : void example2({ r: (state, action) => ({ name: 'Gio Va' }), s: state => 23 })
Expected behavior:
Infer type { name: string } to state in the example2 function as it does correctly in example function.
{ name: string }
state
example2
example
Actual behavior:
In the example2 function the type inferred to state is any.
any
Playground Link:
playground
Related Issues:
The text was updated successfully, but these errors were encountered:
See #30134 - certain parts of inference depend on left-to-right per-parameter inference; we would need unification to infer this correctly
Sorry, something went wrong.
No branches or pull requests
TypeScript Version: 4.0.5
Search Terms:
infer, object literals, interdependencies
Code
Expected behavior:
Infer type
{ name: string }
tostate
in theexample2
function as it does correctly inexample
function.Actual behavior:
In the
example2
function the type inferred tostate
isany
.Playground Link:
playground
Related Issues:
The text was updated successfully, but these errors were encountered: