Skip to content

Commit db45168

Browse files
authored
fix(core): use InstanceType for TE and TD type annotations (#298)
With this change, the `TextEncoder` and `TextDecoder` instances are correctly typed as `InstanceType<typeof TextEncoder>` and `InstanceType<typeof TextDecoder>`, respectively. This ensures that the types are inferred correctly, especially in environments where these classes might not be available globally. Refs: #297
1 parent 9feba2d commit db45168

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/encoders.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*/
1515
export const Empty: Uint8Array = new Uint8Array(0);
1616

17-
export const TE: TextEncoder = new TextEncoder();
18-
export const TD: TextDecoder = new TextDecoder();
17+
export const TE: InstanceType<typeof TextEncoder> = new TextEncoder();
18+
export const TD: InstanceType<typeof TextDecoder> = new TextDecoder();
1919

2020
function concat(...bufs: Uint8Array[]): Uint8Array {
2121
let max = 0;

0 commit comments

Comments
 (0)