Skip to content

Commit ce30b89

Browse files
committed
support extended export syntax
covers - "[abstract] class" - interfaces as per microsoft/TypeScript#3792 (comment) in 2020/12/15 other constructs (microsoft/TypeScript#18628 (comment)) are not yet supported by TypeScript itself
1 parent 543cbe4 commit ce30b89

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

common/corpus/declarations.txt

+19
Original file line numberDiff line numberDiff line change
@@ -832,3 +832,22 @@ let a!: b;
832832
(identifier)
833833
(type_annotation
834834
(type_identifier)))))
835+
836+
====================================
837+
Top-level exports
838+
====================================
839+
840+
export default abstract class C { }
841+
export default class C { }
842+
export class C { }
843+
export default interface I { }
844+
export interface I { }
845+
846+
---
847+
848+
(program
849+
(export_statement (class (type_identifier) (class_body)))
850+
(export_statement (class (type_identifier) (class_body)))
851+
(export_statement (class_declaration (type_identifier) (class_body)))
852+
(export_statement (interface_declaration (type_identifier) (object_type)))
853+
(export_statement (interface_declaration (type_identifier) (object_type))))

common/define-grammar.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,14 @@ module.exports = function defineGrammar(dialect) {
205205
previous,
206206
seq('export', '=', $.identifier, $._semicolon),
207207
seq('export', 'as', 'namespace', $.identifier, $._semicolon),
208-
seq('export', optional("default"), $.function_signature)
208+
seq('export', optional("default"), $.function_signature),
209+
seq(
210+
'export', 'default',
211+
choice(
212+
seq(optional("abstract"), $.class),
213+
$.interface_declaration
214+
)
215+
)
209216
)),
210217

211218
non_null_expression: $ => prec.left(PREC.NON_NULL, seq(

0 commit comments

Comments
 (0)