Skip to content

fix: type errors due to typed array parameterization - #7

Merged
nberlette merged 3 commits into
mainfrom
fix/type-errors
Dec 13, 2025
Merged

nberlette merged 3 commits into
mainfrom
fix/type-errors

Conversation

@nberlette

@nberlette nberlette commented Dec 13, 2025 •

Copy link
Copy Markdown
Owner

Fixes #6.

  • fix: type errors from upstream breaking changes
  • chore: bump version

Copilot AI review requested due to automatic review settings December 13, 2025 07:25
@nberlette nberlette added the bug Something isn't working label Dec 13, 2025
@nberlette nberlette self-assigned this Dec 13, 2025
@nberlette nberlette changed the title fix/type errors fix: type errors due to typed array parameterization Dec 13, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request addresses type errors caused by upstream TypeScript changes to TypedArray parameterization. The changes include adding explicit type annotations and type assertions to fix compatibility issues, along with a minor version bump.

Key changes:

  • Added explicit type parameter to Uint8Array field in TextDecoder class
  • Added type-only import for shim.d.ts to ensure proper type resolution
  • Added type assertions in _internal.ts to satisfy stricter type checking

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/text_decoder.ts Added explicit type annotation to #buffer field to address TypedArray parameterization
src/shim.ts Added type-only import statement for shim.d.ts to ensure type definitions are loaded
src/_internal.ts Added type assertions for TypedArrayPrototype and ArrayBufferPrototypeGetByteLength call to satisfy stricter type checking
deno.json Bumped version from 0.3.2 to 0.4.0 to reflect the fixes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/text_decoder.ts
readonly #ignoreBOM: boolean;

#buffer = new Uint8Array(0);
#buffer: Uint8Array<ArrayBufferLike> = new Uint8Array(0);

Copilot AI Dec 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type parameter for Uint8Array should be ArrayBuffer, not ArrayBufferLike. TypeScript's Uint8Array type is defined as Uint8Array<ArrayBuffer>. Using ArrayBufferLike (which is a union type of ArrayBuffer | SharedArrayBuffer) will cause type errors. Either use Uint8Array<ArrayBuffer> or simply Uint8Array (which defaults to ArrayBuffer).

Suggested change
#buffer: Uint8Array<ArrayBufferLike> = new Uint8Array(0);
#buffer: Uint8Array = new Uint8Array(0);

Copilot uses AI. Check for mistakes.
@nberlette
nberlette merged commit c17b2ae into main Dec 13, 2025
2 checks passed
@nberlette
nberlette deleted the fix/type-errors branch December 13, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: type errors due to generic typed arrays mismatch

2 participants