-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Typescript: Payload type is unknown when all properties of payload are optional #995
New issue
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
Comments
I can't really reproduce that in this TS playground - could you try to reproduce it there? (Note: your "// Becomes..." annotations override the real |
I can confirm it's working in the playground, but not in the VS Code. I even created a clean project with only Could it be a VS Code issue then? As soon as I switch one of the properties to required, the intellisense and validation work correctly. |
Personally I would think more that your If it's something with |
I didn't have a tsconfig when I tried it in a fresh project. {
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"esModuleInterop" : true,
"jsx": "react",
"module": "es6",
"moduleResolution": "Node",
"noImplicitAny": true,
// This is not used with ts-loader
"outDir": "../../dist/",
"paths": {
...
},
"sourceMap": true,
"target": "es5"
}
}
|
Does adding a |
Yes, it does. I didn't know there's a strict mode at all. Anyway, my issue is solved and I am happy again. Feel free to close as far as I'm concerned. Thank you for the assistance. |
Yeah, that's one of those TypeScript ecosystem problems. Using Point is: without And every function call is so ambiguous that it's not really valid for us to make any assumption any more :/ But yeah, we should probably add a disclaimer somewhere. |
Possibly related to: #214
When all properties of a payload are optional, the payload becomes
unknown
.Same goes for actions made with
reducers
property of thecreateSlice
when usingPayloadAction<T>
.Versions:
The text was updated successfully, but these errors were encountered: