Skip to content

Commit

Permalink
Add support for dynamic import() syntax in TS types
Browse files Browse the repository at this point in the history
Turns out this didn't work before, and I tried to use it when setting up code
splitting in the playground.
  • Loading branch information
alangpierce committed Dec 29, 2018
1 parent 16a44ab commit acfcf35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/parser/plugins/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ function tsParseNonArrayType(): void {
case tt._typeof:
tsParseTypeQuery();
return;
case tt._import:
next();
expect(tt.parenL);
expect(tt.string);
expect(tt.parenR);
return;
case tt.braceL:
if (tsLookaheadIsStartOfMappedType()) {
tsParseMappedType();
Expand Down
11 changes: 11 additions & 0 deletions test/typescript-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1324,4 +1324,15 @@ describe("typescript transform", () => {
`,
);
});

it("handles import() types", () => {
assertTypeScriptESMResult(
`
type T = import("./foo");
`,
`
`,
);
});
});

0 comments on commit acfcf35

Please # to comment.