diff --git a/src/parser/plugins/typescript.ts b/src/parser/plugins/typescript.ts index 8f0a1e4f..b8bf6fb6 100644 --- a/src/parser/plugins/typescript.ts +++ b/src/parser/plugins/typescript.ts @@ -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(); diff --git a/test/typescript-test.ts b/test/typescript-test.ts index b14c79da..faad7eb2 100644 --- a/test/typescript-test.ts +++ b/test/typescript-test.ts @@ -1324,4 +1324,15 @@ describe("typescript transform", () => { `, ); }); + + it("handles import() types", () => { + assertTypeScriptESMResult( + ` + type T = import("./foo"); + `, + ` + + `, + ); + }); });