Skip to content

Commit

Permalink
fix: import type definitions (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Apr 27, 2024
1 parent c565b83 commit 492a0aa
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
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

0 comments on commit 492a0aa

Please sign in to comment.