Skip to content

Commit 46a27a2

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 2ac62b3 commit 46a27a2

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
@@ -203,7 +203,14 @@ module.exports = function defineGrammar(dialect) {
203203
export_statement: ($, previous) => prec(PREC.DECLARATION, choice(
204204
previous,
205205
seq('export', '=', $.identifier, $._semicolon),
206-
seq('export', 'as', 'namespace', $.identifier, $._semicolon)
206+
seq('export', 'as', 'namespace', $.identifier, $._semicolon),
207+
seq(
208+
'export', 'default',
209+
choice(
210+
seq(optional("abstract"), $.class),
211+
$.interface_declaration
212+
)
213+
)
207214
)),
208215

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

0 commit comments

Comments
 (0)