Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/twelve-heads-lead.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/acorn-typescript': patch
---

fix: support `export type *`
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3116,9 +3116,15 @@ export function tsPlugin(options?: {
this.importOrExportOuterKind = undefined;
return this.finishNode(decl, 'TSNamespaceExportDeclaration');
} else {
const lookahead2 = this.lookahead(2).type;

// Ideally we can just say "ok this is a type export of some kind"
// but that doesn't work for shouldParseExportStatement() below
// which wants to handle the `export type Foo = ...` case
if (
this.ts_isContextualWithState(enterHead, tokTypes.type) &&
this.lookahead(2).type === tt.braceL
(lookahead2 === tt.braceL || // export type { ... }
lookahead2 === tt.star) // export type *
) {
this.next();
this.importOrExportOuterKind = 'type';
Expand Down
52 changes: 52 additions & 0 deletions test/export_type_star/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"body": [
{
"end": 27,
"exportKind": "type",
"exported": null,
"loc": {
"end": {
"column": 27,
"line": 1
},
"start": {
"column": 0,
"line": 1
}
},
"source": {
"end": 26,
"loc": {
"end": {
"column": 26,
"line": 1
},
"start": {
"column": 19,
"line": 1
}
},
"raw": "'./foo'",
"start": 19,
"type": "Literal",
"value": "./foo"
},
"start": 0,
"type": "ExportAllDeclaration"
}
],
"end": 27,
"loc": {
"end": {
"column": 27,
"line": 1
},
"start": {
"column": 0,
"line": 1
}
},
"sourceType": "module",
"start": 0,
"type": "Program"
}
1 change: 1 addition & 0 deletions test/export_type_star/input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type * from './foo';
Loading