diff options
author | 2023-08-11 18:06:48 -0700 | |
---|---|---|
committer | 2023-08-11 18:06:48 -0700 | |
commit | 43ebffedcdc47da9b9f89a07c9a5d21a7e303722 (patch) | |
tree | 2c0ce4bf3220721217a57c695bd30745c1240efb /src/js_parser.zig | |
parent | ccb9daf7a49f5fc0203ab69ed3d66b8420d1f61d (diff) | |
download | bun-43ebffedcdc47da9b9f89a07c9a5d21a7e303722.tar.gz bun-43ebffedcdc47da9b9f89a07c9a5d21a7e303722.tar.zst bun-43ebffedcdc47da9b9f89a07c9a5d21a7e303722.zip |
Support TypeScript's `export type * as Foo from 'bar'` (#4125)
* [TypeScript] Support `export type * as Foo from 'bar'`
* Update js_parser.zig
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r-- | src/js_parser.zig | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig index a323ed655..3e6143b18 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -9966,16 +9966,37 @@ fn NewParser_( } fn skipTypeScriptTypeStmt(p: *P, opts: *ParseStatementOptions) anyerror!void { - if (opts.is_export and p.lexer.token == .t_open_brace) { - // "export type {foo}" - // "export type {foo} from 'bar'" - _ = try p.parseExportClause(); - if (p.lexer.isContextualKeyword("from")) { - try p.lexer.next(); - _ = try p.parsePath(); + if (opts.is_export) { + switch (p.lexer.token) { + .t_open_brace => { + // "export type {foo}" + // "export type {foo} from 'bar'" + _ = try p.parseExportClause(); + if (p.lexer.isContextualKeyword("from")) { + try p.lexer.next(); + _ = try p.parsePath(); + } + try p.lexer.expectOrInsertSemicolon(); + return; + }, + .t_asterisk => { + // https://github.com/microsoft/TypeScript/pull/52217 + // - export type * as Foo from 'bar'; + // - export type Foo from 'bar'; + try p.lexer.next(); + if (p.lexer.isContextualKeyword("as")) { + // "export type * as ns from 'path'" + try p.lexer.next(); + _ = try p.parseClauseAlias("export"); + try p.lexer.next(); + } + try p.lexer.expectContextualKeyword("from"); + _ = try p.parsePath(); + try p.lexer.expectOrInsertSemicolon(); + return; + }, + else => {}, } - try p.lexer.expectOrInsertSemicolon(); - return; } const name = p.lexer.identifier; |