Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nick/utf8",
"version": "0.3.2",
"version": "0.4.0",
"license": "MIT",
"author": {
"name": "Nicholas Berlette",
Expand Down Expand Up @@ -28,6 +28,11 @@
"fix": "deno fmt && deno lint --fix",
"ok": "deno fmt --check && deno lint && deno run test"
},
"lint": {
"rules": {
"exclude": ["no-import-prefix"]
}
},
"lock": false,
"nodeModulesDir": "auto",
"publish": {
Expand Down
4 changes: 2 additions & 2 deletions src/_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const TypedArray: TypedArrayConstructor = ObjectGetPrototypeOf(
Uint8Array,
);
export const TypedArrayPrototype: InstanceType<TypedArrayConstructor> =
TypedArray?.prototype!;
TypedArray?.prototype! as InstanceType<TypedArrayConstructor>;
export const TypedArrayPrototypeGetToStringTag: {
(target: unknown): TypedArrayToStringTag | undefined;
} = uncurryGetter(TypedArrayPrototype, Symbol.toStringTag) as any;
Expand Down Expand Up @@ -274,7 +274,7 @@ export function toUint8Array(input?: BufferSource | null): Uint8Array {
return new Uint8Array(input);
} catch (_) {
try {
ArrayBufferPrototypeGetByteLength(input);
ArrayBufferPrototypeGetByteLength(input as ArrayBuffer);
return new Uint8Array(input);
} catch (_) {
throw new TypeError(
Expand Down
2 changes: 2 additions & 0 deletions src/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* ```
* @module shim
*/
import type {} from "./shim.d.ts";

import { TextEncoder } from "./text_encoder.ts";
import { TextDecoder } from "./text_decoder.ts";
import { TextDecoderStream, TextEncoderStream } from "./streams.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/text_decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class TextDecoder {
readonly #fatal: boolean;
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.

/**
* Creates a new TextDecoder instance.
Expand Down