Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -3350,6 +3350,14 @@ The WASI instance has already started.

The WASI instance has not been started.

<a id="ERR_WEBASSEMBLY_NOT_SUPPORTED"></a>

### `ERR_WEBASSEMBLY_NOT_SUPPORTED`

A feature requiring WebAssembly was used, but WebAssembly is not supported or
has been disabled in the current environment (for example, when running with
`--jitless`). The error message specifies which feature requires WebAssembly.

<a id="ERR_WEBASSEMBLY_RESPONSE"></a>

### `ERR_WEBASSEMBLY_RESPONSE`
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,9 @@ E('ERR_VM_MODULE_NOT_MODULE',
'Provided module is not an instance of Module', Error);
E('ERR_VM_MODULE_STATUS', 'Module status %s', Error);
E('ERR_WASI_ALREADY_STARTED', 'WASI instance has already started', Error);
E('ERR_WEBASSEMBLY_NOT_SUPPORTED',
'WebAssembly is not supported in this environment, but is required for %s',
Error);
E('ERR_WEBASSEMBLY_RESPONSE', 'WebAssembly response %s', TypeError);
E('ERR_WORKER_INIT_FAILED', 'Worker initialization failure: %s', Error);
E('ERR_WORKER_INVALID_EXEC_ARGV', (errors, msg = 'invalid execArgv flags') =>
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ const {
SymbolPrototypeGetDescription,
SymbolReplace,
SymbolSplit,
globalThis,
} = primordials;

const {
codes: {
ERR_NO_CRYPTO,
ERR_NO_TYPESCRIPT,
ERR_UNKNOWN_SIGNAL,
ERR_WEBASSEMBLY_NOT_SUPPORTED,
},
isErrorStackTraceLimitWritable,
overrideStackTrace,
Expand Down Expand Up @@ -244,6 +246,8 @@ function assertCrypto() {
function assertTypeScript() {
if (noTypeScript)
throw new ERR_NO_TYPESCRIPT();
if (globalThis.WebAssembly === undefined)
throw new ERR_WEBASSEMBLY_NOT_SUPPORTED('TypeScript');
}

/**
Expand Down
11 changes: 11 additions & 0 deletions test/es-module/test-typescript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,14 @@ test('check transform types warning', async () => {
assert.match(result.stdout, /Hello, TypeScript!/);
assert.strictEqual(result.code, 0);
});

test('expect error when executing a TypeScript file with --jitless', async () => {
const result = await spawnPromisified(process.execPath, [
'--jitless',
fixtures.path('typescript/ts/test-typescript.ts'),
]);

assert.match(result.stderr, /ERR_WEBASSEMBLY_NOT_SUPPORTED/);
assert.match(result.stderr, /WebAssembly is not supported in this environment, but is required for TypeScript/);
assert.strictEqual(result.code, 1);
});
Loading