Skip to content

fix(core): use InstanceType for TE and TD type annotations - #298

Merged
aricart merged 1 commit into
nats-io:mainfrom
Roseidon:main
Jul 9, 2025
Merged

aricart merged 1 commit into
nats-io:mainfrom
Roseidon:main

Conversation

@Roseidon

@Roseidon Roseidon commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

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
Resolves: #297

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: nats-io#297
@aricart

aricart commented Jul 9, 2025

Copy link
Copy Markdown
Member

The change is innocuous enough - however given your setup on the issue, you'll still get tsc errors if you don't have the dom library or something that shims a W3C websocket.

@aricart aricart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: 'TextEncoder' refers to a value, but is being used as a type here. Did you mean 'typeof TextEncoder'?

2 participants