Skip to content

Add typings for explicit resource management #24196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RReverser
Copy link
Collaborator

@RReverser RReverser commented Apr 28, 2025

This is a follow-up to #23818.

When targeting an existing ES version like ES2024, TypeScript transpiles using ... and doesn't require any typings.

However, when targeting ESNext, it expects using ... to be a native feature, and then looks up [Symbol.dispose] in the type and fails with a type validation error if it doesn't exist.

Since there's no way to do conditional compilation based on target version in TS, I'm adding this property to type declarations but marking with ts-ignore so that Symbol.dispose not existing is not an error in versions below ESNext.

@RReverser RReverser requested review from brendandahl and sbc100 April 28, 2025 12:38
This is a follow-up to emscripten-core#23818.

When targeting any existing ES version, TypeScript transpiles `using ...` and doesn't require any typings.

However, when targeting ESNext, it expects `using ...` to be a native feature, and then looks up `[Symbol.dispose]` in the type and fails with a type validation error if it doesn't exist.

Since there's no way to do conditional compilation based on target version in TS, I'm adding this property to type declarations but marking with `ts-ignore` so that `Symbol.dispose` not existing is not an error in versions below ESNext.
@RReverser RReverser force-pushed the symbol-dispose-typings branch from 96f03f7 to 2e7524c Compare April 28, 2025 23:06
@RReverser RReverser enabled auto-merge (squash) April 28, 2025 23:06
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.

2 participants