Skip to content

Commit

Permalink
support extended export syntax
Browse files Browse the repository at this point in the history
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
  • Loading branch information
resolritter committed Jan 29, 2021
1 parent 2ac62b3 commit 46a27a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
19 changes: 19 additions & 0 deletions common/corpus/declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -832,3 +832,22 @@ let a!: b;
(identifier)
(type_annotation
(type_identifier)))))

====================================
Top-level exports
====================================

export default abstract class C { }
export default class C { }
export class C { }
export default interface I { }
export interface I { }

---

(program
(export_statement (class (type_identifier) (class_body)))
(export_statement (class (type_identifier) (class_body)))
(export_statement (class_declaration (type_identifier) (class_body)))
(export_statement (interface_declaration (type_identifier) (object_type)))
(export_statement (interface_declaration (type_identifier) (object_type))))
9 changes: 8 additions & 1 deletion common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,14 @@ module.exports = function defineGrammar(dialect) {
export_statement: ($, previous) => prec(PREC.DECLARATION, choice(
previous,
seq('export', '=', $.identifier, $._semicolon),
seq('export', 'as', 'namespace', $.identifier, $._semicolon)
seq('export', 'as', 'namespace', $.identifier, $._semicolon),
seq(
'export', 'default',
choice(
seq(optional("abstract"), $.class),
$.interface_declaration
)
)
)),

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

0 comments on commit 46a27a2

Please sign in to comment.