Skip to content

Commit 2063ff7

Browse files
committed
support extended import 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 7db0dcf commit 2063ff7

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
@@ -824,3 +824,22 @@ let a!: b;
824824
(identifier)
825825
(type_annotation
826826
(type_identifier)))))
827+
828+
====================================
829+
Top-level exports
830+
====================================
831+
832+
export default abstract class C { }
833+
export default class C { }
834+
export class C { }
835+
export default interface I { }
836+
export interface I { }
837+
838+
---
839+
840+
(program
841+
(export_statement (class (type_identifier) (class_body)))
842+
(export_statement (class (type_identifier) (class_body)))
843+
(export_statement (class_declaration (type_identifier) (class_body)))
844+
(export_statement (interface_declaration (type_identifier) (object_type)))
845+
(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)