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

error TS2315: Type 'Buffer' is not generic #216

Open
apeloquin-agilysys opened this issue Dec 16, 2024 · 1 comment
Open

error TS2315: Type 'Buffer' is not generic #216

apeloquin-agilysys opened this issue Dec 16, 2024 · 1 comment

Comments

@apeloquin-agilysys
Copy link

Environment Information

  • OS: Mac M3 Sonoma 14.6.1
  • Node Version: 20.14.0
  • NPM Version: 10.7.0
  • confluent-kafka-javascript version: 0.5.2

Steps to Reproduce

Update existing Typescript app with schemaregistry dependency from 0.6.1 to 1.0.0 and compile.

> tsc --outDir ./dist --project ./tsconfig.json

../../node_modules/@confluentinc/schemaregistry/dist/rules/encryption/encrypt-executor.d.ts:41:32 - error TS2315: Type 'Buffer' is not generic.

41     static readonly EMPTY_AAD: Buffer<ArrayBuffer>;
                                  ~~~~~~~~~~~~~~~~~~~

../../node_modules/@confluentinc/schemaregistry/dist/serde/serde.d.ts:8:34 - error TS2315: Type 'Buffer' is not generic.

8 export declare const MAGIC_BYTE: Buffer<ArrayBuffer>;
                                   ~~~~~~~~~~~~~~~~~~~


Found 2 errors in 2 files.

Errors  Files
     1  ../../node_modules/@confluentinc/schemaregistry/dist/rules/encryption/encrypt-executor.d.ts:41
     1  ../../node_modules/@confluentinc/schemaregistry/dist/serde/serde.d.ts:8
npm error Lifecycle script `build` failed with error:
npm error Error: command failed

This can be worked around by enabling skipLibCheck in the tsconfig.json...

  "compilerOptions": {
    "skipLibCheck": true
  }

...but that feels like bypassing a legitimate type issue.

As the error says the built-in Buffer type doesn't support generics and I can't find any definition of a non-built-in Buffer type in the project.

$ grep  -r "Buffer<" .
./dist/rules/encryption/encrypt-executor.d.ts:    static readonly EMPTY_AAD: Buffer<ArrayBuffer>;
./dist/serde/serde.d.ts:export declare const MAGIC_BYTE: Buffer<ArrayBuffer>;
@rayokota
Copy link
Member

@apeloquin-agilysys the change for Buffer becoming generic looks like it's coming from TypeScript 5.7 and es2024, see https://devblogs.microsoft.com/typescript/announcing-typescript-5-7/#typedarrays-are-now-generic-over-arraybufferlike.
Are you using those?

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

No branches or pull requests

2 participants