fix: type errors due to typed array parameterization - #7
Conversation
There was a problem hiding this comment.
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
Uint8Arrayfield in TextDecoder class - Added type-only import for
shim.d.tsto ensure proper type resolution - Added type assertions in
_internal.tsto 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.
| readonly #ignoreBOM: boolean; | ||
|
|
||
| #buffer = new Uint8Array(0); | ||
| #buffer: Uint8Array<ArrayBufferLike> = new Uint8Array(0); |
There was a problem hiding this comment.
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).
| #buffer: Uint8Array<ArrayBufferLike> = new Uint8Array(0); | |
| #buffer: Uint8Array = new Uint8Array(0); |
Fixes #6.