Skip to content

Commit

Permalink
fix: import and export types
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Musat authored and gabotechs committed Dec 24, 2022
1 parent da15ea6 commit 9244f11
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/js/grammar/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ExportDeconstruction struct {
}

type DeclarationExport struct {
Name string `"export" "async"? ("let"|"const"|"var"|"function"|"class") ALL? @Ident`
Name string `"export" "async"? ("let"|"const"|"var"|"function"|"class"|"type"|"interface") ALL? @Ident`
}

type ListExport struct {
Expand Down
8 changes: 8 additions & 0 deletions internal/js/grammar/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func TestExport(t *testing.T) {
Name: `export function* generatorFunctionName() { /* … */ }`,
ExpectedDeclaration: []string{"generatorFunctionName"},
},
{
Name: `export type MyType`,
ExpectedDeclaration: []string{"MyType"},
},
{
Name: `export interface MyInterface`,
ExpectedDeclaration: []string{"MyInterface"},
},
{
Name: `export { name1, nameN };`,
ExpectedList: []AliasedName{
Expand Down
2 changes: 1 addition & 1 deletion internal/js/grammar/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Imported struct {
}

type StaticImport struct {
Imported *Imported `"import" (@@ "from")?`
Imported *Imported `"import" "type"? (@@ "from")?`
Path string `@String`
}

Expand Down
4 changes: 4 additions & 0 deletions internal/js/grammar/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func TestImport(t *testing.T) {
Name: "import { Something } from 'file'",
ExpectedStatic: []string{"file"},
},
{
Name: "import type { Something } from 'file'",
ExpectedStatic: []string{"file"},
},
{
Name: "import { One, Other } from 'file'",
ExpectedStatic: []string{"file"},
Expand Down

0 comments on commit 9244f11

Please sign in to comment.