Add TS support to @babel/parser's Scope (#9766)

* [parser] Allow plugins to extend ScopeHandler

* Directly extend Scope

* Don't use new.target to get the ScopeHandler

* [parser] Add TS enum  support to the Scope

* Remove duplicated options in tests

* Fix

* Fix flow

* Rename tests

* Add tests

* Full typescript support in scope

* Remove BIND_SIMPLE_CATCH

SCOPE_SIMPLE_CATCH was used instead

* Export TS types

* Register function declarations

* Fix body-less functions and namespaces

1) Move this.scope.exit() for functions from parseFunctionBody to the callers.
    Otherwise the scope of body-less functions was never closed.
    Also, it is easier to track scope.exit() if it is near to scope.enter()
2) Register namespace ids for export

* Disallow redeclaration of enum with const enum
This commit is contained in:
Nicolò Ribaudo
2019-04-26 14:19:53 +02:00
committed by GitHub
parent 293f3c98d2
commit 30d507c915
108 changed files with 3974 additions and 98 deletions

View File

@@ -2016,7 +2016,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
checkLVal(
expr: N.Expression,
bindingType: ?BindingTypes = BIND_NONE,
bindingType: BindingTypes = BIND_NONE,
checkClashes: ?{ [key: string]: boolean },
contextDescription: string,
): void {