GeezerVison is showing github.com — lib: fix TypeScript support check in jitless mode · nodejs/node@f55a5fe
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/errors.md +8Lines changed: 8 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3350,6 +3350,14 @@ The WASI instance has already started. | 3350 | 3350 |
| 3351 | 3351 | The WASI instance has not been started. | 3352 | 3352 |
| | 3353 | +<a id="ERR_WEBASSEMBLY_NOT_SUPPORTED"></a> | | 3354 | + | | 3355 | +### `ERR_WEBASSEMBLY_NOT_SUPPORTED` | | 3356 | + | | 3357 | +A feature requiring WebAssembly was used, but WebAssembly is not supported or | | 3358 | +has been disabled in the current environment (for example, when running with | | 3359 | +`--jitless`). The error message specifies which feature requires WebAssembly. | | 3360 | + | 3353 | 3361 | <a id="ERR_WEBASSEMBLY_RESPONSE"></a> | 3354 | 3362 |
| 3355 | 3363 | ### `ERR_WEBASSEMBLY_RESPONSE` | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/errors.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1905,6 +1905,9 @@ E('ERR_VM_MODULE_NOT_MODULE', | 1905 | 1905 | 'Provided module is not an instance of Module', Error); | 1906 | 1906 | E('ERR_VM_MODULE_STATUS', 'Module status %s', Error); | 1907 | 1907 | E('ERR_WASI_ALREADY_STARTED', 'WASI instance has already started', Error); | | 1908 | +E('ERR_WEBASSEMBLY_NOT_SUPPORTED', | | 1909 | + 'WebAssembly is not supported in this environment, but is required for %s', | | 1910 | + Error); | 1908 | 1911 | E('ERR_WEBASSEMBLY_RESPONSE', 'WebAssembly response %s', TypeError); | 1909 | 1912 | E('ERR_WORKER_INIT_FAILED', 'Worker initialization failure: %s', Error); | 1910 | 1913 | E('ERR_WORKER_INVALID_EXEC_ARGV', (errors, msg = 'invalid execArgv flags') => | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/util.js +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,13 +46,15 @@ const { | 46 | 46 | SymbolPrototypeGetDescription, | 47 | 47 | SymbolReplace, | 48 | 48 | SymbolSplit, | | 49 | + globalThis, | 49 | 50 | } = primordials; | 50 | 51 |
| 51 | 52 | const { | 52 | 53 | codes: { | 53 | 54 | ERR_NO_CRYPTO, | 54 | 55 | ERR_NO_TYPESCRIPT, | 55 | 56 | ERR_UNKNOWN_SIGNAL, | | 57 | + ERR_WEBASSEMBLY_NOT_SUPPORTED, | 56 | 58 | }, | 57 | 59 | isErrorStackTraceLimitWritable, | 58 | 60 | overrideStackTrace, | @@ -244,6 +246,8 @@ function assertCrypto() { | 244 | 246 | function assertTypeScript() { | 245 | 247 | if (noTypeScript) | 246 | 248 | throw new ERR_NO_TYPESCRIPT(); | | 249 | + if (globalThis.WebAssembly === undefined) | | 250 | + throw new ERR_WEBASSEMBLY_NOT_SUPPORTED('TypeScript'); | 247 | 251 | } | 248 | 252 |
| 249 | 253 | /** | |
Collapse file Copy file name to clipboardExpand all lines: test/es-module/test-typescript.mjs +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -342,3 +342,14 @@ test('check transform types warning', async () => { | 342 | 342 | assert.match(result.stdout, /Hello, TypeScript!/); | 343 | 343 | assert.strictEqual(result.code, 0); | 344 | 344 | }); | | 345 | + | | 346 | +test('expect error when executing a TypeScript file with --jitless', async () => { | | 347 | + const result = await spawnPromisified(process.execPath, [ | | 348 | + '--jitless', | | 349 | + fixtures.path('typescript/ts/test-typescript.ts'), | | 350 | + ]); | | 351 | + | | 352 | + assert.match(result.stderr, /ERR_WEBASSEMBLY_NOT_SUPPORTED/); | | 353 | + assert.match(result.stderr, /WebAssembly is not supported in this environment, but is required for TypeScript/); | | 354 | + assert.strictEqual(result.code, 1); | | 355 | +}); |
|