fix(types): specify ArrayBuffer as a backing buffer type for TextEncoder.encode() (#30434)

This commit is contained in:
Yusuke Tanaka 2025-09-03 06:54:13 +09:00 committed by GitHub
parent 9c197682f9
commit 6523e3f49b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -452,12 +452,6 @@ interface TextEncoderEncodeIntoResult {
written: number;
}
/** @category Encoding */
interface TextEncoder extends TextEncoderCommon {
/** Returns the result of running UTF-8's encoder. */
encode(input?: string): Uint8Array;
encodeInto(input: string, dest: Uint8Array): TextEncoderEncodeIntoResult;
}
/**
* Allows you to convert a string into binary data (in the form of a Uint8Array)
* given the encoding.
@ -474,10 +468,13 @@ interface TextEncoder extends TextEncoderCommon {
*/
interface TextEncoder extends TextEncoderCommon {
/** Turns a string into binary data (in the form of a Uint8Array) using UTF-8 encoding. */
encode(input?: string): Uint8Array;
encode(input?: string): Uint8Array<ArrayBuffer>;
/** Encodes a string into the destination Uint8Array and returns the result of the encoding. */
encodeInto(input: string, dest: Uint8Array): TextEncoderEncodeIntoResult;
encodeInto(
input: string,
dest: Uint8Array<ArrayBufferLike>,
): TextEncoderEncodeIntoResult;
}
/** @category Encoding */