Skip to content

Commit 2d1c7d5

Browse files
authored
Support decorators on abstract classes (#127)
* support decorators on abstract classes * regenerate parser for 'abstract_class_decorator' Co-authored-by: resolritter <[email protected]>
1 parent a3a4bec commit 2d1c7d5

File tree

5 files changed

+78271
-77679
lines changed

5 files changed

+78271
-77679
lines changed

common/corpus/declarations.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,10 @@ abstract class Animal {
744744
}
745745
}
746746

747+
@bar
748+
abstract class Foo {
749+
}
750+
747751
---
748752

749753
(program
@@ -782,7 +786,11 @@ abstract class Animal {
782786
function: (member_expression
783787
object: (identifier)
784788
property: (property_identifier))
785-
arguments: (arguments (string)))))))))
789+
arguments: (arguments (string))))))))
790+
(abstract_class_declaration
791+
decorator: (decorator (identifier))
792+
name: (type_identifier)
793+
body: (class_body)))
786794

787795
==================================
788796
Index type queries

common/define-grammar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ module.exports = function defineGrammar(dialect) {
354354
),
355355

356356
abstract_class_declaration: $ => seq(
357+
repeat(field('decorator', $.decorator)),
357358
'abstract',
358359
'class',
359360
field('name', $._type_identifier),

typescript/src/grammar.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6985,6 +6985,17 @@
69856985
"abstract_class_declaration": {
69866986
"type": "SEQ",
69876987
"members": [
6988+
{
6989+
"type": "REPEAT",
6990+
"content": {
6991+
"type": "FIELD",
6992+
"name": "decorator",
6993+
"content": {
6994+
"type": "SYMBOL",
6995+
"name": "decorator"
6996+
}
6997+
}
6998+
},
69886999
{
69897000
"type": "STRING",
69907001
"value": "abstract"

typescript/src/node-types.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,16 @@
325325
}
326326
]
327327
},
328+
"decorator": {
329+
"multiple": true,
330+
"required": false,
331+
"types": [
332+
{
333+
"type": "decorator",
334+
"named": true
335+
}
336+
]
337+
},
328338
"name": {
329339
"multiple": false,
330340
"required": true,

0 commit comments

Comments
 (0)