Skip to content

Commit c60846c

Browse files
committed
Add more test cases
1 parent e127694 commit c60846c

File tree

6 files changed

+243060
-242612
lines changed

6 files changed

+243060
-242612
lines changed

common/corpus/types.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ import type UserID, {addUser, removeUser} from './User.js';
319319

320320
import type from './User.js';
321321
import type, {addUser} from './User.js';
322+
import {type} from './User.js';
323+
import {addUser as type} from './User.js';
324+
import {type as addUser} from './User.js';
325+
import {type, addUser} from './User.js';
326+
import {addUser, type} from './User.js';
322327
import type, {addUser, type User} from './User.js';
323328

324329
---
@@ -341,6 +346,21 @@ import type, {addUser, type User} from './User.js';
341346
(import_statement
342347
(import_clause (identifier)
343348
(named_imports (import_specifier (identifier)))) (string (string_fragment)))
349+
(import_statement
350+
(import_clause
351+
(named_imports (import_specifier (identifier)))) (string (string_fragment)))
352+
(import_statement
353+
(import_clause
354+
(named_imports (import_specifier (identifier) (identifier)))) (string (string_fragment)))
355+
(import_statement
356+
(import_clause
357+
(named_imports (import_specifier (identifier) (identifier)))) (string (string_fragment)))
358+
(import_statement
359+
(import_clause
360+
(named_imports (import_specifier (identifier)) (import_specifier (identifier)))) (string (string_fragment)))
361+
(import_statement
362+
(import_clause
363+
(named_imports (import_specifier (identifier)) (import_specifier (identifier)))) (string (string_fragment)))
344364
(import_statement
345365
(import_clause (identifier)
346366
(named_imports (import_specifier (identifier)) (import_specifier (identifier)))) (string (string_fragment))))

common/define-grammar.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,14 @@ module.exports = function defineGrammar(dialect) {
264264

265265
import_specifier: ($, previous) => seq(
266266
optional(choice('type', 'typeof')),
267-
previous
268-
),
267+
choice(
268+
field('name', choice($.identifier, alias('type', $.identifier))),
269+
seq(
270+
field('name', choice($._module_export_name, alias('type', $.identifier))),
271+
'as',
272+
field('alias', choice($.identifier, alias('type', $.identifier)))
273+
),
274+
)),
269275

270276
import_clause: ($, previous) => choice(
271277
$.namespace_import,

tsx/src/grammar.json

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,22 @@
734734
"type": "FIELD",
735735
"name": "name",
736736
"content": {
737-
"type": "SYMBOL",
738-
"name": "identifier"
737+
"type": "CHOICE",
738+
"members": [
739+
{
740+
"type": "SYMBOL",
741+
"name": "identifier"
742+
},
743+
{
744+
"type": "ALIAS",
745+
"content": {
746+
"type": "STRING",
747+
"value": "type"
748+
},
749+
"named": true,
750+
"value": "identifier"
751+
}
752+
]
739753
}
740754
},
741755
{
@@ -745,8 +759,22 @@
745759
"type": "FIELD",
746760
"name": "name",
747761
"content": {
748-
"type": "SYMBOL",
749-
"name": "_module_export_name"
762+
"type": "CHOICE",
763+
"members": [
764+
{
765+
"type": "SYMBOL",
766+
"name": "_module_export_name"
767+
},
768+
{
769+
"type": "ALIAS",
770+
"content": {
771+
"type": "STRING",
772+
"value": "type"
773+
},
774+
"named": true,
775+
"value": "identifier"
776+
}
777+
]
750778
}
751779
},
752780
{
@@ -757,8 +785,22 @@
757785
"type": "FIELD",
758786
"name": "alias",
759787
"content": {
760-
"type": "SYMBOL",
761-
"name": "identifier"
788+
"type": "CHOICE",
789+
"members": [
790+
{
791+
"type": "SYMBOL",
792+
"name": "identifier"
793+
},
794+
{
795+
"type": "ALIAS",
796+
"content": {
797+
"type": "STRING",
798+
"value": "type"
799+
},
800+
"named": true,
801+
"value": "identifier"
802+
}
803+
]
762804
}
763805
}
764806
]

0 commit comments

Comments
 (0)