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

Backport type fixes from v11.0.1 to v10 #355

Closed
wolfy1339 opened this issue Sep 24, 2024 · 7 comments
Closed

Backport type fixes from v11.0.1 to v10 #355

wolfy1339 opened this issue Sep 24, 2024 · 7 comments

Comments

@wolfy1339
Copy link

When using LRUCache with TypeScript 5.6.2 the build spits out warnings

Error: node_modules/lru-cache/dist/esm/index.d.ts(1032,5): error TS2416: Property 'forEach' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'.

lru-cache 10.4.3
Node 18
TypeScript 5.6.2

Ref: octokit/auth-app.js#644

@wolfy1339
Copy link
Author

Error: node_modules/lru-cache/dist/esm/index.d.ts(1032,5): error TS2416: Property 'forEach' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'.
  Type '(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any) => void' is not assignable to type '(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => void'.
    Types of parameters 'fn' and 'callbackfn' are incompatible.
      Types of parameters 'map' and 'self' are incompatible.
        Type 'LRUCache<K, V, FC>' is not assignable to type 'Map<K, V>'.
          The types returned by 'entries().next(...)' are incompatible between these types.
            Type 'IteratorResult<[K, V], void>' is not assignable to type 'IteratorResult<[K, V], undefined>'.
              Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<[K, V], undefined>'.
                Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'.
                  Type 'void' is not assignable to type 'undefined'.

@AviVahl
Copy link

AviVahl commented Sep 26, 2024

this already got fixed in v11.0.1 by the following commit:
5ed947d

problem is... deps out there cannot upgrade to v11 without dropping Node 18... which some still support.
e.g. probot/probot#2057

@isaacs any chance this fix can be backported to v10 as well?

@wolfy1339 wolfy1339 changed the title Property 'forEach' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>' Backport type fixes from v11.0.1 to v10 Sep 26, 2024
@isaacs
Copy link
Owner

isaacs commented Sep 26, 2024

No. Turn on skipLibCheck: true in your tsconfig, as recommended by Microsoft's official TypeScript documentation.

@isaacs isaacs closed this as completed Sep 26, 2024
@isaacs
Copy link
Owner

isaacs commented Sep 26, 2024

Or just don't upgrade TypeScript until you're ready to upgrade node. Or fork this library. Or copy it into your lib folder and make whatever changes you want to it. Really, you have so many options, the license is incredibly liberal.

@AviVahl
Copy link

AviVahl commented Sep 27, 2024

No. Turn on skipLibCheck: true in your tsconfig, as recommended by Microsoft's official TypeScript documentation.

Turning type checking globally off for .d.ts files would hide the issue, yes. It would also potentially hide many other issues, some of which my team experienced in the past.

Or just don't upgrade TypeScript until you're ready to upgrade node. Or fork this library. Or copy it into your lib folder and make whatever changes you want to it. Really, you have so many options, the license is incredibly liberal.

We're indeed using latest LTS Node. it's third parties which still need/want to support Node 18. Considering 18 is not EOL, I believe this to be reasonable.

Forking the library would not do us much good, as it's used by a third party. Forking two libraries just to remove implements Map from a .d.ts file seems like an overkill.

Seeing most of the millions of downloads this library had in the past week is of v10, and some of those use typescript without disableLibCheck, I'd kindly ask you to reconsider.

@isaacs
Copy link
Owner

isaacs commented Sep 27, 2024

You're not the first to ask, but I won't reconsider, sorry. The answer is the same, regardless of the number of people asking.

It's unrewarding work, so I won't do it for free. But for $500/month subscription, I will gladly maintain a legacy version of this library indefinitely, and back port whatever fixes or improvements are possible to be ported in nonbreaking ways.

@isaacs
Copy link
Owner

isaacs commented Sep 27, 2024

Or, just don't upgrade TS until you can upgrade node. Like, this is not a challenging puzzle to solve.

wolfy1339 added a commit to probot/probot that referenced this issue Nov 5, 2024
See isaacs/node-lru-cache#355

The package author is unwilling to backport the proper fix to the previous version.
wolfy1339 added a commit to octokit/auth-app.js that referenced this issue Nov 5, 2024
wolfy1339 added a commit to octokit/auth-app.js that referenced this issue Nov 5, 2024
wolfy1339 added a commit to octokit/auth-app.js that referenced this issue Nov 5, 2024
wolfy1339 added a commit to probot/probot that referenced this issue Nov 5, 2024
See isaacs/node-lru-cache#355

The package author is unwilling to backport the proper fix to the previous version.
mpodwysocki added a commit to Azure/azure-sdk-for-js that referenced this issue Feb 3, 2025
…32845)

### Packages impacted by this PR

- @azure/schema-registry-avro

### Issues associated with this PR

- #32416
- #32837
- #32835

### Describe the problem that is addressed by this PR

- Removes the `uuid` and `types/uuid` module in favor of `randomUUID`
from `@azure/core-util`.
- Adds snippets for the README
- Fixes the type issues with the LRU-Cache due to breaking changes as
noted here [isaacs/node-lru-cache#355]

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
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

No branches or pull requests

3 participants