-
Notifications
You must be signed in to change notification settings - Fork 16
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
Type errors #37
Comments
Hi! Happy to investigate this, but can you give me a code example of what produces this error? |
Sure thing! import memoize from 'micro-memoize'
function callAPI<T>(url: string): Promise<T> {
return fetch(url).then((res) => res.json())
}
const getCountries = memoize(
async () => {
const { Countries } = await callAPI<{
Countries: ICountryAPI[]
}>('https://fdgdfgdfgdfgdfg.com/api/countries')
return Countries
},
{ isPromise: true }
) I think the problem is that I use strict mode in my TS-config, but your package doesn't, so that's why your package types incompatible with my code. |
Alright I have a PR up, and it isn't great but it should do the trick. Inherently when building these kinds of libraries where you use raw JS hacks for performance, the "clean code" methodology TS espouses kind of gets compromised. I have published a beta of the patch fix, you should be able to install as |
Yes! It works! |
* use strict: true in tsconfig attempt to fix #37 * update exposed types also, change PassedOptions to Options to be backwards compatible * Release 4.0.8-beta.0
Hi there, I have similar problem. TS 4.1 introduced new compilerOption noUncheckedIndexedAccess. see: When I use TS 4.1 or above with this option, micro-memoize fails to compile. To reproduce bug, create a project with TS 4.1 or above, turn on noUncheckedIndexedAccess, import and use micro-memoize and run a TS build. I see:
|
Alright I can tackle this over the weekend I think, but @ondrejvelisek would you mind creating a new issue for this? It will help with mapping the solution to the issue. |
Sure thing. It is here: #76 |
Hello!
"micro-memoize": "^4.0.6"
I have a bunch of type errors related with micro-memoize:
tsconfig
The text was updated successfully, but these errors were encountered: