Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import type definitions #172

Merged
merged 2 commits into from
Apr 27, 2024
Merged
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
2 changes: 1 addition & 1 deletion lib/lexer.asm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/lexer.emcc.asm.js

Large diffs are not rendered by default.

Binary file modified lib/lexer.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions src/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ void addImport (const char16_t* statement_start, const char16_t* start, const ch
}
else if (dynamic == STANDARD_IMPORT) {
import->statement_end = end + 1;
import->import_ty = Dynamic;
import->import_ty = Static;
}
else {
import->statement_end = 0;
import->import_ty = Static;
import->import_ty = Dynamic;
}
import->start = start;
import->end = end;
Expand Down
22 changes: 22 additions & 0 deletions test/_unit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ function assertExportIs(source, actual, expected) {
suite('Lexer', () => {
beforeEach(async () => await init);

test('import types', () => {
const input = `
// dynamic
const { a } = await import('a');
const { b } = await import.source('b');
// static
import b from 'b';
import { c } from 'c';
import source z from 'z';
// meta
import.meta.url
`;

const [imports] = parse(input);
assert.strictEqual(imports[0].t, 2);
assert.strictEqual(imports[1].t, 5);
assert.strictEqual(imports[2].t, 1);
assert.strictEqual(imports[3].t, 1);
assert.strictEqual(imports[4].t, 4);
assert.strictEqual(imports[5].t, 3);
});

test(`Regex case`, () => {
const source = `for(let t of/[0-9]+/g.exec(e)){}`
parse(source);
Expand Down
Loading