uuidjs / uuid

Generate RFC-compliant UUIDs in JavaScript
MIT License
14.65k stars 904 forks source link

fix: compatibility with Typescript V4 #837

Closed bobvandevijver closed 2 weeks ago

bobvandevijver commented 2 weeks ago

With https://github.com/uuidjs/uuid/pull/833 the type export was added, but the export type * syntax is only available since Typescript V5. Using direct imports should resolve the issue.

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#support-for-export-type- for the documentation on this.

broofa commented 2 weeks ago

Thanks for the contribution.

FWIW, I specifically requested the wildcard export to make this code more future-proof. I am admittedly reluctant to go back on that.

This prompted me to do a bit of digging to figure out what our TS support policy should be since that hasn't really been discussed yet. Based on this comment, it sounds like there's good precedent for adopting a policy of supporting TS versions less than two years old, only. This also aligns roughly with our long-standing node support policy (LTS versions + one prior).

As it turns out, TS 4.9 - the last 4.X version released - will fall below that bar at the end of this week. I promise, I did not plan this. 😄

Given the above, I don't see a need for this change.

bobvandevijver commented 2 weeks ago

@broofa First of all, thanks for doing the research on this!

While I understand the reasoning behind your decision, I do find it a bit harsh to just drop a major typescript version in a patch release only because of a type export that has just a little bit of overhead and which also isn't very common to change (its not like we have new UUID versions dropping every month).

As it turns out, TS 4.9 - the last 4.X version released - will fall below that bar at the end of this week.

4.9.5 has been released on Jan 31, 2023.

In the very least some documentation about this support choice should be provided, but I do hope that we can get Typescript V4 support back in v11 and to drop it with good documentation in v12.

broofa commented 2 weeks ago

TS4.9.5 appears to work just fine with uuid@11.0.3, both on the command line and VSCode. Here's the test I used....

uuid-ts-types-test.zip

Given that and that uuid@11 has only been out for three weeks, and TS@4 falling off the support matrix for other similar projects (Definitely typed, typescript-eslint)... I'm okay leaving things as they stand.

bobvandevijver commented 2 weeks ago

@broofa That would be because you have explicitly disabled the check in your test with skipLibCheck: true. If you remove that line you will see the error directly.