Skip to content
File

Blob: src/workerd/api/tests/new-module-registry-ts-test.js

javascript24 lines
1// Copyright (c) 2026 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4// Test that TypeScript modules work correctly with the new module registry
5// when the typescript_strip_types compat flag is enabled. This exercises the
6// transpiler path where the source is owned by a rust::String that may have
7// shorter lifetime than the module registry.
8 
9import { strictEqual } from 'assert';
10import { add, greet, PI } from 'ts-helper';
11 
12strictEqual(add(2, 3), 5);
13strictEqual(greet('world'), 'hello, world');
14strictEqual(PI, 3.14159);
15 
16export const dynamicImportTs = {
17 async test() {
18 const mod = await import('ts-helper');
19 strictEqual(mod.add(10, 20), 30);
20 strictEqual(mod.greet('test'), 'hello, test');
21 strictEqual(mod.PI, 3.14159);
22 },
23};