Skip to content

lib: fix TypeScript support check in jitless mode - #61382

Closed
Han5991 wants to merge 2 commits into
nodejs:mainfrom
Han5991:fix-jitless-typescript-error
Closed

Han5991 wants to merge 2 commits into
nodejs:mainfrom
Han5991:fix-jitless-typescript-error

Conversation

@Han5991

@Han5991 Han5991 commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

The internal TypeScript stripper relies on WebAssembly, which is disabled in --jitless mode. This PR updates
assertTypeScript to explicitly throw ERR_WEBASSEMBLY_NOT_SUPPORTED instead of failing obscurely when WebAssembly
is unavailable.

A regression test has been added to test/es-module/test-typescript.mjs.

image

Fixes: #61353

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originating in Node.js core. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Jan 14, 2026
@Han5991
Han5991 force-pushed the fix-jitless-typescript-error branch from 202f642 to e56e36b Compare January 14, 2026 13:27
Comment thread doc/api/errors.md Resolved

@marco-ippolito marco-ippolito 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.

This PR is not performing any check, it just added an error that is not used anywhere. The error should be thrown when lazily initializing the typescript parser

@Han5991

Han5991 commented Jan 14, 2026

Copy link
Copy Markdown
Contributor Author

This PR is not performing any check, it just added an error that is not used anywhere. The error should be thrown when lazily initializing the typescript parser

Thanks for the feedback. I'll review the logic and move the check to the appropriate place as suggested. I will also improve the error message to be more descriptive.

@Han5991
Han5991 force-pushed the fix-jitless-typescript-error branch 2 times, most recently from 08c7bc7 to e6cb215 Compare January 14, 2026 14:06
Comment thread doc/api/errors.md Resolved
Comment thread lib/internal/errors.js Resolved
Comment thread lib/internal/modules/typescript.js Resolved
@Han5991
Han5991 force-pushed the fix-jitless-typescript-error branch from bf1ec67 to ca857df Compare January 14, 2026 14:38
WebAssembly is disabled when Node.js is run with --jitless. The
internal TypeScript stripper relies on WebAssembly, and previously
failed obscurely with a ReferenceError in this mode.

This commit adds an explicit check for WebAssembly support when
loading the TypeScript parser. If WebAssembly is unavailable,
it now throws a descriptive ERR_WEBASSEMBLY_NOT_SUPPORTED error.

Fixes: nodejs#61353
@Han5991
Han5991 force-pushed the fix-jitless-typescript-error branch from ca857df to ef5444a Compare January 14, 2026 14:44
@codecov

codecov Bot commented Jan 14, 2026 •