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
Better Typescript types #117
Comments
The library is already written in TypeScript. Ideally, you shouldn't do anything do get types working. Isn't it working for you? |
With the built-in types, it doesn't infer much:
|
@Linksku You're not using the function correctly. Please, take a look at the README again. |
But I agree that it will be much better with TS 4 spreads. And it'll hopefully fix #109. |
Hmm it does work after I remove my type, not sure what I did wrong initially, thanks! |
Closes #109 Closes #117 BREAKING CHANGE: Types now depend on TypeScript v4.0. BREAKING CHANGE: The deprecated function/object API has been removed. **Before**: ```jsx import createUseContext from "constate"; const useCounterContext = createUseContext(useCounter); <useCounterContext.Provider> ... </useCounterContext.Provider> ``` **After**: ```jsx import constate from "constate"; const [CounterProvider, useCounterContext] = constate(useCounter); <CounterProvider> ... </CounterProvider> ```
I'm learning TS and spent a long time figuring out how to type Constate properly, turns out it wasn't possible in TS 3, I needed TS 4:
Since TS 4 is still in beta, this shouldn't be included in Constate yet, but I thought I'd share. Let me know if there's anything that can be improved!
The text was updated successfully, but these errors were encountered: