Skip to content

Commit 1b3b549

Browse files
test(transpile): add test for bare export ancillary types
1 parent b79e433 commit 1b3b549

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package fixtures:bare-export-with-result;
2+
3+
world component {
4+
export foo: func(res: result<string, string>);
5+
}

packages/jco-transpile/test/typegen.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,21 @@ suite('Type Generation', () => {
7171
assert(interfaceDeclarationContent.includes('export { _delete as delete };'));
7272
assert(interfaceDeclarationContent.includes('function _delete'));
7373
});
74+
75+
// https://github.com/bytecodealliance/jco/issues/627
76+
test('bare exports with ancillary types', async () => {
77+
const files = await generateHostTypes(`${WIT_FIXTURE_DIR}/bare-export-with-result.wit`, {
78+
worldName: 'fixtures:bare-export-with-result/component',
79+
guest: true,
80+
});
81+
82+
assert.strictEqual(Object.keys(files).length, 1);
83+
assert.strictEqual(Object.keys(files)[0], 'component.d.ts');
84+
85+
const [worldDeclaration] = Object.values(files);
86+
const worldDeclarationContent = new TextDecoder().decode(worldDeclaration);
87+
88+
assert.include(worldDeclarationContent, 'export type Result<T, E>');
89+
assert.include(worldDeclarationContent, 'declare module');
90+
});
7491
});

packages/jco-transpile/test/vitest.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,16 @@ const REPORTERS = process.env.GITHUB_ACTIONS ? ['verbose', 'github-actions'] : [
66

77
export default defineConfig({
88
test: {
9-
retry: 3,
109
reporters: REPORTERS,
1110
disableConsoleIntercept: true,
1211
printConsoleTrace: true,
1312
passWithNoTests: false,
14-
include: ['test/*.js'],
15-
exclude: ['test/helpers.js'],
13+
include: ['test/*.ts'],
14+
exclude: ['test/helpers.ts'],
1615
testTimeout: DEFAULT_TIMEOUT_MS,
1716
hookTimeout: DEFAULT_TIMEOUT_MS,
1817
teardownTimeout: DEFAULT_TIMEOUT_MS,
18+
execArgv: ['--expose-gc'],
1919
pool: 'forks',
20-
poolOptions: {
21-
forks: {
22-
execArgv: ['--expose-gc'],
23-
},
24-
},
2520
},
2621
});

0 commit comments

Comments
 (0)