Skip to content

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

Closed

Description

@Servonius

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

Activity

  1. spawnrider commented on Jan 7, 2025

    @spawnrider

    Same for me here. Need to rollback to 11.0.3.

  2. andyf0x commented on Jan 7, 2025

    @andyf0x

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

  3. broofa commented on Jan 7, 2025

    @broofa
    Member

    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?

  4. 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[/+] on Jan 7, 2025
  5. 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[/+] on Jan 7, 2025
  6. broofa commented on Jan 7, 2025

    @broofa
    Member

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

  7. gabynevada commented on Jan 7, 2025

    @gabynevada

    @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

  8. andyf0x commented on Jan 8, 2025

    @andyf0x

    @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?

  9. broofa commented on Jan 9, 2025

    @broofa
    Member

    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 typescript@5.0.4. 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.

  10. broofa commented on Jan 9, 2025

    @broofa
    Member

    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.

  11. david-schopf-senacor commented on Jan 9, 2025

    @david-schopf-senacor

    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
    
    
  12. ExpliuM commented on Jan 9, 2025

    @ExpliuM

    Same here

  13. andyf0x commented on Jan 9, 2025

    @andyf0x

    Unless someone here objects, I thinki the best solution is to pin the dependency to typescript@5.0.4. 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".

  14. broofa commented on Jan 9, 2025

    @broofa
    Member

    Fix published in uuid@11.0.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy