Skip to content
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

Support of TS 4.1 with noUncheckedIndexedAccess #76

Closed
ondrejvelisek opened this issue Apr 21, 2022 · 1 comment · Fixed by #77
Closed

Support of TS 4.1 with noUncheckedIndexedAccess #76

ondrejvelisek opened this issue Apr 21, 2022 · 1 comment · Fixed by #77

Comments

@ondrejvelisek
Copy link

Hi there,

I have similar problem as #37
TS 4.1 introduced new compilerOption noUncheckedIndexedAccess. see:
https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess

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:

tsc --noEmit

node_modules/micro-memoize/src/Cache.ts:82:23 - error TS2345: Argument of type 'Key | undefined' is not assignable to parameter of type 'Key'.
  Type 'undefined' is not assignable to type 'any[]'.

82     if (isMatchingKey(keys[0], keyToMatch)) {
                         ~~~~~~~

node_modules/micro-memoize/src/Cache.ts:88:27 - error TS2345: Argument of type 'Key | undefined' is not assignable to parameter of type 'Key'.
  Type 'undefined' is not assignable to type 'any[]'.

88         if (isMatchingKey(keys[index], keyToMatch)) {
                             ~~~~~~~~~~~

node_modules/micro-memoize/src/Cache.ts:176:13 - error TS2339: Property 'length' does not exist on type 'Key | undefined'.

176     const { length } = existingKey;
                ~~~~~~

node_modules/micro-memoize/src/Cache.ts:186:22 - error TS2532: Object is possibly 'undefined'.

186         if (!isEqual(existingKey[index], keyToMatch[index])) {
                         ~~~~~~~~~~~

node_modules/micro-memoize/src/Cache.ts:194:20 - error TS2532: Object is possibly 'undefined'.

194     return isEqual(existingKey[0], keyToMatch[0]) ? 0 : -1;
                       ~~~~~~~~~~~

node_modules/micro-memoize/src/Cache.ts:220:7 - error TS2322: Type 'Key | undefined' is not assignable to type 'Key'.
  Type 'undefined' is not assignable to type 'any[]'.

220       keys[index + 1] = keys[index];
          ~~~~~~~~~~~~~~~

node_modules/micro-memoize/src/Cache.ts:269:43 - error TS2345: Argument of type 'Key | undefined' is not assignable to parameter of type 'RawKey'.
  Type 'undefined' is not assignable to type 'RawKey'.

269         const keyIndex = this.getKeyIndex(firstKey);
                                              ~~~~~~~~


Found 7 errors in the same file, starting at: node_modules/micro-memoize/src/Cache.ts:82
@planttheidea
Copy link
Owner

This should be fixed as-of 4.0.10. If you have any more issues, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants