-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Mapped type for combineReducers in index.d.ts #2177
Conversation
Updated typescript to 2.1.4 Updated typescript-definition-tester to 0.0.5 Updated typescript tests to use proper import Added mapped type to index.d.ts
This doesn't only allow for more convenient type inference: Assuming your Reducers are defined properly, this will also enforce, at compile time, most (or all?) of the validation done in It will also solve an issue where
In other words, a function that returns This does make the typedef much more strict though. It is a breaking change for people who ignored the above warnings, or people who use the |
@kevinthiart you're right, but ts 2.1 is also a breaking change so. Btw, I don't see any other places where |
Since this is a breaking change, shouldn't this be rebased onto the Let's also update export type Reducer<S> = <A extends Action>(state: S | undefined, action: A) => S; |
Updated Reducer<S> type in index.d.ts Add strictNullChecks flag to typescript spec
@aikoven I've added strict null check to spec & undefined to reducer. Not sure what needs to be done with the |
cc. @timdorr |
@mkusher I'm not sure of how this would be handled according to semver, but I think it would be a bad idea to break typing compatibility on a patch or minor version bump. The conservative approach would be to wait until the next major, which is what the I would see about getting these typings published under the @types npm namespace too. Those can be versioned independently of the library, to correspond better with TS features. |
Closing this PR in favor of #2182 |
Since typescript 2.1 there is a cool feature microsoft/TypeScript#12114 which can improve type inference for
combineReducers
. No need to explicitly pass state type tocombineReducers
any more.Note: it requires typescript 2.1