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

[BUG] 11.0.4 "[ERROR] TS2315: Type 'Uint8Array' is not generic. [plugin angular-compiler]" build error in Angular 18 and 19 #856

Closed
2 tasks done
Servonius opened this issue Jan 7, 2025 · 12 comments · Fixed by #860
Labels

Comments

@Servonius
Copy link

Servonius commented Jan 7, 2025

Before you begin...

  • I have searched the existing issues
  • I am not using version 13.x of node (if so, please upgrade)

Description of the problem

The latest patch version 11.0.4 is no longer usable with Angular 18 and 19 because the patch version is requiring Typescript 5.7 which is not supported by Angular 18 and 19.

It worked with previous 11.0.X versions.

It causes the following build error:

✘ [ERROR] TS2315: Type 'Uint8Array' is not generic. [plugin angular-compiler]
    node_modules/uuid/dist/cjs/parse.d.ts:1:38:
      1 │ declare function parse(uuid: string): Uint8Array<ArrayBuffer>;
        ╵                                       ~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2315: Type 'Uint8Array' is not generic. [plugin angular-compiler]
    node_modules/uuid/dist/cjs/v35.d.ts:2:52:
      2 │ ...clare function stringToBytes(str: string): Uint8Array<ArrayBuffer>;
        ╵                                               ~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2315: Type 'Uint8Array' is not generic. [plugin angular-compiler]
    node_modules/uuid/dist/cjs/v35.d.ts:6:165:
      6 │ ...Uint8Array, offset?: number): string | Uint8Array<ArrayBufferLike>;
        ╵                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~

Recipe for reproducing

No response

Additional information

No response

Environment

No response

@Servonius Servonius added the bug label Jan 7, 2025
@spawnrider
Copy link

Same for me here. Need to rollback to 11.0.3.

@andyf0x
Copy link

andyf0x commented Jan 7, 2025

Same here, but for Angular 16. Fixing on 11.0.3 has resolved the issue.

@broofa
Copy link
Member

broofa commented Jan 7, 2025

For future reference, this is exactly why we have this in the issue template:

"IMPORTANT: Failure to provide a Minimal, Complete, and Verifiable example will result in this issue being closed without further review."

I can confirm the uuid typedefs changed between 11.0.3 and 11.0.4 as a result of updating from TS 5.6 -> 5.7. But I don't have a way of easily reproducing your issue so my interest / ability in fixing this is limited. That this would cause breaking changes is unexpected, given that TS 5.6 -> 5.7 is a semver-minor change.

That said... the TS blog post about this recommends updating to the latest @types/node version. Can one of you try that and report back here on whether or not that fixes the problem?

@broofa broofa changed the title [BUG] 11.0.4 no longer usable with Angular 18 and 19 [BUG] 11.0.4 "Type 'Uint8Array' is not generic" build error in Angular 18 and 19 Jan 7, 2025
@broofa broofa changed the title [BUG] 11.0.4 "Type 'Uint8Array' is not generic" build error in Angular 18 and 19 [BUG] 11.0.4 "[ERROR] TS2315: Type 'Uint8Array' is not generic. [plugin angular-compiler]" build error in Angular 18 and 19 Jan 7, 2025
@broofa
Copy link
Member

broofa commented Jan 7, 2025

Related TS issue microsoft/TypeScript#60638 (marked as "not a defect", fwiw)

@gabynevada
Copy link

@broofa I'm still getting the issue on the latest @types/node package. The issue seems to be typescript package incompatibility.

Typescript does not follow semver (microsoft/TypeScript#14116) so all minor versions can include and most times include breaking changes.

On angular projects they don't support typescript 5.7 yet so the fix for now is reverting to 11.0.3

@andyf0x
Copy link

andyf0x commented Jan 8, 2025

@broofa On most normal dependencies this would probably have been fine. But this concerns Typescript, so any changes can be very impactful, it strictly compiles everyone's code-bases, so can result in many different experiences. The fact that the TS update 5.6 -> 5.7 was treated as a semver-minor change, but was rolled into UUID as a semver-patch from 11.0.3 -> 11.0.4 is what's hurting a lot right now. Also no mention of this TS dependency upgrade on the 11.0.4 change log.

Does the 11.0.4 release need the TS 5.7 upgrade? If not, could a 11.0.5 patch with a TS 5.6 downgrade be an option?

@broofa
Copy link
Member

broofa commented Jan 9, 2025

Does the 11.0.4 release need the TS 5.7 upgrade?

Nope. That update was just my muscle memory kicking in. I've been in the habit of updating all the dev dependencies on this project whenever I sit down to work on it. Historically, that hasn't been an issue as none of those dependencies changed the API. That's also why that update got flagged as a "chore", which is why it doesn't show up in the CHANGELOG.

Obviously the addition of built-in TS support and the typescript dependency break that... so... yeah, this is just me catching up to the TS support requirements.

Unless someone here objects, I thinki the best solution is to pin the dependency to [email protected]. That should (?) insure support for the last two years of TS releases, which is the support strategy I find myself settling on for TypeScript. I'm not aware of any features introduced since then that are critical to this project.

@broofa
Copy link
Member

broofa commented Jan 9, 2025

REQUEST: Can someone here put up an MRE example of this problem, please. E.g. a small code snippet that depends on uuid (but not angular) that breaks when compiled with tsc?

I'd like to put some unit tests in place that capture TS support issues like this.

@david-schopf-senacor
Copy link

david-schopf-senacor commented Jan 9, 2025

Reproduction example

package.json

  {
  "dependencies": {
    "@types/node": "22.10.5",
    "typescript": "5.5.4",
    "uuid": "11.0.4"
  }
}

index.ts
import { v4 } from "uuid";

Run tsc
node_modules/typescript/bin/tsc index.ts

Result

node_modules/uuid/dist/cjs/parse.d.ts:1:39 - error TS2315: Type 'Uint8Array' is not generic.

1 declare function parse(uuid: string): Uint8Array<ArrayBuffer>;
                                        ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/uuid/dist/cjs/v35.d.ts:2:53 - error TS2315: Type 'Uint8Array' is not generic.

2 export declare function stringToBytes(str: string): Uint8Array<ArrayBuffer>;
                                                      ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/uuid/dist/cjs/v35.d.ts:6:166 - error TS2315: Type 'Uint8Array' is not generic.

6 export default function v35(version: 0x30 | 0x50, hash: HashFunction, value: string | Uint8Array, namespace: UUIDTypes, buf?: Uint8Array, offset?: number): string | Uint8Array<ArrayBufferLike>;
                                                                                                                                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 3 errors in 2 files.

Errors  Files
     1  node_modules/uuid/dist/cjs/parse.d.ts:1
     2  node_modules/uuid/dist/cjs/v35.d.ts:2

@ExpliuM
Copy link

ExpliuM commented Jan 9, 2025

Same here

@andyf0x
Copy link

andyf0x commented Jan 9, 2025

Unless someone here objects, I thinki the best solution is to pin the dependency to [email protected]. That should (?) insure support for the last two years of TS releases, which is the support strategy I find myself settling on for TypeScript. I'm not aware of any features introduced since then that are critical to this project.

@broofa No real objections to fixing on that specific version, but I have seen in a few projects that they currently pin their TypeScript dependency like this : "typescript": ">=4.9.3 <5.2".

@broofa
Copy link
Member

broofa commented Jan 9, 2025

Fix published in [email protected].

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