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
Function generic unmatched
https://www.typescriptlang.org/play/?ts=5.4.5#code/KYDwDg9gTgLgBDAnmYcDKMCGNgDECuAdgMYwCWEhAPBtsAHxwC8cAFAFBxdwDOAXOiw4ANJ24A6SZigBzfnEyFEAbQC67AJTNGixAG527UJFgJkqAGr5QGaMADyYcpR5UxXWiPdwAshAAm+AA2wDyijCwA3t48QsAA-AKeqAA+bKxaTIzJWmmRbBpJcXAAvgbccAC2+EIUhDyJcABKwMTQ-lSxUGSEMsKCdAQkztTJ9PTl3JUBwaGN0RUVygDWcD1wy8CIEABmvjMhPKoCVjYwdo4jrn6Bhyuq-YTAAG7AUPTeZewlhsbQ8DsiKQ6nBiFBgHRbOC3BVknBQDhCP4eM1Wu1OjBur1+kRloQIAB3Qj0UQVG6zFEI4BIlEtNpQDpdHp9VH0xmY5k4wh4wnEknseisCBOOryU4gKEOEUuGhxfrkw70LTRH7sNr1eCxOzMUHgyHncGsBbcWJ0DJwfLgmD4KCEC1wABG0gATAIAIylUqkqY1bCigT5HrEASsU04N3OgDMmUYYeAEcj4idUGdAGpU17vNNbqEA94KjsIBA84tS3AAPTl3hxEMxtj5ZOuuAekoafqVuAAFQAFmQUVVsMRuwhu6g45My9wO3GBIDhiDzcbJ1wOxUrTa7Q2Xe7ShPlx2Su2qwAhGojvugxQAchg+bLccXd+XXHXtvtjZ3X2fXEPFarin8LtexRYhr1vb8-2rOgA0dbdmy9OAn0WapahcGCgxDOM6zjJMXXTTMkMPT5RFbAwgA
export type StateFunction<State> = ( s: State, ...args: any[] ) => any; export type VuexStoreOptions< State, Modules, > = { state?: State | (() => State) | { (): State }; mutations?: Record<string, StateFunction<State>>; modules?: { [k in keyof Modules]: VuexStoreOptions<Modules[k], never> }; } export function createStore< State extends Record<string, unknown>, Modules extends Record<string, Record<string, unknown>>, >(options: VuexStoreOptions<State, Modules>) { } const store = createStore({ state() { return { bar2: 1 } }, mutations: { inc: (state123) => state123.bar2++ }, modules: { foo: { // state: () => ({ bar2: 1 }), // This match the state; // state: function () { // return { bar2: 1 }; // }, // But this can't state() { return { bar2: 1 }; }, // and This can't // state: { bar2: 1 }, mutations: { inc: (state) => state.bar2++ }, }, }, });
If use arrow function or obj method function to declare the state in modules.foo
modules.foo
Got error: 'state.bar2' is of type 'unknown'.
But arrow function won't.
No matter which one i use to declare the fucntion ( arrow function, method function or just function), the state can be known in mutations param
No response
The text was updated successfully, but these errors were encountered:
See #47599
Sorry, something went wrong.
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
π Search Terms
Function generic unmatched
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.4.5#code/KYDwDg9gTgLgBDAnmYcDKMCGNgDECuAdgMYwCWEhAPBtsAHxwC8cAFAFBxdwDOAXOiw4ANJ24A6SZigBzfnEyFEAbQC67AJTNGixAG527UJFgJkqAGr5QGaMADyYcpR5UxXWiPdwAshAAm+AA2wDyijCwA3t48QsAA-AKeqAA+bKxaTIzJWmmRbBpJcXAAvgbccAC2+EIUhDyJcABKwMTQ-lSxUGSEMsKCdAQkztTJ9PTl3JUBwaGN0RUVygDWcD1wy8CIEABmvjMhPKoCVjYwdo4jrn6Bhyuq-YTAAG7AUPTeZewlhsbQ8DsiKQ6nBiFBgHRbOC3BVknBQDhCP4eM1Wu1OjBur1+kRloQIAB3Qj0UQVG6zFEI4BIlEtNpQDpdHp9VH0xmY5k4wh4wnEknseisCBOOryU4gKEOEUuGhxfrkw70LTRH7sNr1eCxOzMUHgyHncGsBbcWJ0DJwfLgmD4KCEC1wABG0gATAIAIylUqkqY1bCigT5HrEASsU04N3OgDMmUYYeAEcj4idUGdAGpU17vNNbqEA94KjsIBA84tS3AAPTl3hxEMxtj5ZOuuAekoafqVuAAFQAFmQUVVsMRuwhu6g45My9wO3GBIDhiDzcbJ1wOxUrTa7Q2Xe7ShPlx2Su2qwAhGojvugxQAchg+bLccXd+XXHXtvtjZ3X2fXEPFarin8LtexRYhr1vb8-2rOgA0dbdmy9OAn0WapahcGCgxDOM6zjJMXXTTMkMPT5RFbAwgA
π» Code
π Actual behavior
If use arrow function or obj method function to declare the state in
modules.foo
Got error:
'state.bar2' is of type 'unknown'.
But arrow function won't.
π Expected behavior
No matter which one i use to declare the fucntion ( arrow function, method function or just function),
the state can be known in mutations param
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: