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

@@ -9,7 +9,7 @@ export default class BaseParser {
// Properties set by constructor in index.js
options: Options;
inModule: boolean;
scope: ScopeHandler;
scope: ScopeHandler<*>;
plugins: PluginsMap;
filename: ?string;
sawUnambiguousESM: boolean = false;

View File

@@ -1767,6 +1767,7 @@ export default class ExpressionParser extends LValParser {
this.parseFunctionParams((node: any), allowModifiers);
this.checkYieldAwaitInDefaultParams();
this.parseFunctionBodyAndFinish(node, type, true);
this.scope.exit();
this.state.yieldPos = oldYieldPos;
this.state.awaitPos = oldAwaitPos;
@@ -1795,6 +1796,7 @@ export default class ExpressionParser extends LValParser {
if (params) this.setArrowFunctionParameters(node, params);
this.parseFunctionBody(node, true);
this.scope.exit();
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
this.state.yieldPos = oldYieldPos;
this.state.awaitPos = oldAwaitPos;
@@ -1890,7 +1892,6 @@ export default class ExpressionParser extends LValParser {
node.body = this.parseBlock(true, false);
this.state.labels = oldLabels;
}
this.scope.exit();
this.state.inParameters = oldInParameters;
// Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'

View File

@@ -20,6 +20,8 @@ export default class Parser extends StatementParser {
options = getOptions(options);
super(options, input);
const ScopeHandler = this.getScopeHandler();
this.options = options;
this.inModule = this.options.sourceType === "module";
this.scope = new ScopeHandler(this.raise.bind(this), this.inModule);
@@ -27,6 +29,11 @@ export default class Parser extends StatementParser {
this.filename = options.sourceFilename;
}
// This can be overwritten, for example, by the TypeScript plugin.
getScopeHandler(): Class<ScopeHandler<*>> {
return ScopeHandler;
}
parse(): File {
this.scope.enter(SCOPE_PROGRAM);
const file = this.startNode();

View File

@@ -16,7 +16,7 @@ import type {
import type { Pos, Position } from "../util/location";
import { isStrictBindReservedWord } from "../util/identifier";
import { NodeUtils } from "./node";
import { type BindingTypes, BIND_NONE, BIND_OUTSIDE } from "../util/scopeflags";
import { type BindingTypes, BIND_NONE } from "../util/scopeflags";
export default class LValParser extends NodeUtils {
// Forward-declaration: defined in expression.js
@@ -325,7 +325,7 @@ export default class LValParser extends NodeUtils {
checkLVal(
expr: Expression,
bindingType: ?BindingTypes = BIND_NONE,
bindingType: BindingTypes = BIND_NONE,
checkClashes: ?{ [key: string]: boolean },
contextDescription: string,
): void {
@@ -363,7 +363,7 @@ export default class LValParser extends NodeUtils {
checkClashes[key] = true;
}
}
if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) {
if (!(bindingType & BIND_NONE)) {
this.scope.declareName(expr.name, bindingType, expr.start);
}
break;

View File

@@ -11,7 +11,7 @@ import {
import { lineBreak, skipWhiteSpace } from "../util/whitespace";
import * as charCodes from "charcodes";
import {
BIND_SIMPLE_CATCH,
BIND_CLASS,
BIND_LEXICAL,
BIND_VAR,
BIND_FUNCTION,
@@ -662,12 +662,7 @@ export default class StatementParser extends ExpressionParser {
clause.param = this.parseBindingAtom();
const simple = clause.param.type === "Identifier";
this.scope.enter(simple ? SCOPE_SIMPLE_CATCH : 0);
this.checkLVal(
clause.param,
simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL,
null,
"catch clause",
);
this.checkLVal(clause.param, BIND_LEXICAL, null, "catch clause");
this.expect(tt.parenR);
} else {
clause.param = null;
@@ -1056,22 +1051,6 @@ export default class StatementParser extends ExpressionParser {
if (isStatement) {
node.id = this.parseFunctionId(requireId);
if (node.id && !isHangingStatement) {
// If it is a regular function declaration in sloppy mode, then it is
// subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
// mode depends on properties of the current scope (see
// treatFunctionsAsVar).
this.checkLVal(
node.id,
this.state.strict || node.generator || node.async
? this.scope.treatFunctionsAsVar
? BIND_VAR
: BIND_LEXICAL
: BIND_FUNCTION,
null,
"function name",
);
}
}
const oldInClassProperty = this.state.inClassProperty;
@@ -1099,6 +1078,15 @@ export default class StatementParser extends ExpressionParser {
);
});
this.scope.exit();
if (isStatement && !isHangingStatement) {
// We need to validate this _after_ parsing the function body
// because of TypeScript body-less function declarations,
// which shouldn't be added to the scope.
this.checkFunctionStatementId(node);
}
this.state.inClassProperty = oldInClassProperty;
this.state.yieldPos = oldYieldPos;
this.state.awaitPos = oldAwaitPos;
@@ -1125,6 +1113,25 @@ export default class StatementParser extends ExpressionParser {
this.checkYieldAwaitInDefaultParams();
}
checkFunctionStatementId(node: N.Function): void {
if (!node.id) return;
// If it is a regular function declaration in sloppy mode, then it is
// subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
// mode depends on properties of the current scope (see
// treatFunctionsAsVar).
this.checkLVal(
node.id,
this.state.strict || node.generator || node.async
? this.scope.treatFunctionsAsVar
? BIND_VAR
: BIND_LEXICAL
: BIND_FUNCTION,
null,
"function name",
);
}
// Parse a class declaration or literal (depending on the
// `isStatement` parameter).
@@ -1612,7 +1619,7 @@ export default class StatementParser extends ExpressionParser {
if (this.match(tt.name)) {
node.id = this.parseIdentifier();
if (isStatement) {
this.checkLVal(node.id, BIND_LEXICAL, undefined, "class name");
this.checkLVal(node.id, BIND_CLASS, undefined, "class name");
}
} else {
if (optionalId || !isStatement) {

View File

@@ -105,7 +105,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 {

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 {

View File

@@ -1,12 +1,23 @@
// @flow
import type { TokenType } from "../tokenizer/types";
import { types as tt } from "../tokenizer/types";
import { types as ct } from "../tokenizer/context";
import * as N from "../types";
import type { Pos, Position } from "../util/location";
import Parser from "../parser";
import { type BindingTypes, BIND_NONE, SCOPE_OTHER } from "../util/scopeflags";
import type { TokenType } from "../../tokenizer/types";
import { types as tt } from "../../tokenizer/types";
import { types as ct } from "../../tokenizer/context";
import * as N from "../../types";
import type { Pos, Position } from "../../util/location";
import type Parser from "../../parser";
import {
type BindingTypes,
BIND_NONE,
SCOPE_OTHER,
BIND_TS_ENUM,
BIND_TS_CONST_ENUM,
BIND_TS_TYPE,
BIND_TS_INTERFACE,
BIND_TS_FN_TYPE,
BIND_TS_NAMESPACE,
} from "../../util/scopeflags";
import TypeScriptScopeHandler from "./scope";
type TsModifier =
| "readonly"
@@ -69,6 +80,10 @@ function keywordTypeFromName(
export default (superClass: Class<Parser>): Class<Parser> =>
class extends superClass {
getScopeHandler(): Class<TypeScriptScopeHandler> {
return TypeScriptScopeHandler;
}
tsIsIdentifier(): boolean {
// TODO: actually a bit more complex in TypeScript, but shouldn't matter.
// See https://github.com/Microsoft/TypeScript/issues/15008
@@ -1017,6 +1032,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
node: N.TsInterfaceDeclaration,
): N.TsInterfaceDeclaration {
node.id = this.parseIdentifier();
this.checkLVal(
node.id,
BIND_TS_INTERFACE,
undefined,
"typescript interface declaration",
);
node.typeParameters = this.tsTryParseTypeParameters();
if (this.eat(tt._extends)) {
node.extends = this.tsParseHeritageClause("extends");
@@ -1031,6 +1052,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
node: N.TsTypeAliasDeclaration,
): N.TsTypeAliasDeclaration {
node.id = this.parseIdentifier();
this.checkLVal(node.id, BIND_TS_TYPE, undefined, "typescript type alias");
node.typeParameters = this.tsTryParseTypeParameters();
node.typeAnnotation = this.tsExpectThenParseType(tt.eq);
this.semicolon();
@@ -1099,6 +1122,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
): N.TsEnumDeclaration {
if (isConst) node.const = true;
node.id = this.parseIdentifier();
this.checkLVal(
node.id,
isConst ? BIND_TS_CONST_ENUM : BIND_TS_ENUM,
undefined,
"typescript enum declaration",
);
this.expect(tt.braceL);
node.members = this.tsParseDelimitedList(
"EnumMembers",
@@ -1126,11 +1156,22 @@ export default (superClass: Class<Parser>): Class<Parser> =>
tsParseModuleOrNamespaceDeclaration(
node: N.TsModuleDeclaration,
nested?: boolean = false,
): N.TsModuleDeclaration {
node.id = this.parseIdentifier();
if (!nested) {
this.checkLVal(
node.id,
BIND_TS_NAMESPACE,
null,
"module or namespace declaration",
);
}
if (this.eat(tt.dot)) {
const inner = this.startNode();
this.tsParseModuleOrNamespaceDeclaration(inner);
this.tsParseModuleOrNamespaceDeclaration(inner, true);
node.body = inner;
} else {
node.body = this.tsParseModuleBlock();
@@ -1260,7 +1301,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
switch (starttype) {
case tt._function:
return this.parseFunctionStatement(nany);
return this.parseFunctionStatement(
nany,
/* async */ false,
/* declarationPosition */ true,
);
case tt._class:
return this.parseClass(
nany,
@@ -1531,6 +1576,14 @@ export default (superClass: Class<Parser>): Class<Parser> =>
super.parseFunctionBodyAndFinish(node, type, isMethod);
}
checkFunctionStatementId(node: N.Function): void {
if (!node.body && node.id) {
this.checkLVal(node.id, BIND_TS_FN_TYPE, null, "function name");
} else {
super.checkFunctionStatementId(...arguments);
}
}
parseSubscript(
base: N.Expression,
startPos: number,
@@ -2214,7 +2267,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 {

View File

@@ -0,0 +1,105 @@
// @flow
import ScopeHandler, { Scope } from "../../util/scope";
import {
BIND_KIND_TYPE,
BIND_FLAGS_TS_ENUM,
BIND_FLAGS_TS_CONST_ENUM,
BIND_FLAGS_TS_EXPORT_ONLY,
BIND_KIND_VALUE,
BIND_FLAGS_CLASS,
type ScopeFlags,
type BindingTypes,
} from "../../util/scopeflags";
import * as N from "../../types";
class TypeScriptScope extends Scope {
types: string[] = [];
// enums (which are also in .types)
enums: string[] = [];
// const enums (which are also in .enums and .types)
constEnums: string[] = [];
// classes (which are also in .lexical) and interface (which are also in .types)
classes: string[] = [];
// namespaces and bodyless-functions are too difficult to track,
// especially without type analysis.
// We need to track them anyway, to avoid "X is not defined" errors
// when exporting them.
exportOnlyBindings: string[] = [];
}
// See https://github.com/babel/babel/pull/9766#discussion_r268920730 for an
// explanation of how typescript handles scope.
export default class TypeScriptScopeHandler extends ScopeHandler<TypeScriptScope> {
createScope(flags: ScopeFlags): TypeScriptScope {
return new TypeScriptScope(flags);
}
declareName(name: string, bindingType: BindingTypes, pos: number) {
const scope = this.currentScope();
if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {
this.maybeExportDefined(scope, name);
scope.exportOnlyBindings.push(name);
return;
}
super.declareName(...arguments);
if (bindingType & BIND_KIND_TYPE) {
if (!(bindingType & BIND_KIND_VALUE)) {
// "Value" bindings have already been registered by the superclass.
this.checkRedeclarationInScope(scope, name, bindingType, pos);
this.maybeExportDefined(scope, name);
}
scope.types.push(name);
}
if (bindingType & BIND_FLAGS_TS_ENUM) scope.enums.push(name);
if (bindingType & BIND_FLAGS_TS_CONST_ENUM) scope.constEnums.push(name);
if (bindingType & BIND_FLAGS_CLASS) scope.classes.push(name);
}
isRedeclaredInScope(
scope: TypeScriptScope,
name: string,
bindingType: BindingTypes,
): boolean {
if (scope.enums.indexOf(name) > -1) {
if (bindingType & BIND_FLAGS_TS_ENUM) {
// Enums can be merged with other enums if they are both
// const or both non-const.
const isConst = !!(bindingType & BIND_FLAGS_TS_CONST_ENUM);
const wasConst = scope.constEnums.indexOf(name) > -1;
return isConst !== wasConst;
}
return true;
}
if (bindingType & BIND_FLAGS_CLASS && scope.classes.indexOf(name) > -1) {
if (scope.lexical.indexOf(name) > -1) {
// Classes can be merged with interfaces
return !!(bindingType & BIND_KIND_VALUE);
} else {
// Interface can be merged with other classes or interfaces
return false;
}
}
if (bindingType & BIND_KIND_TYPE && scope.types.indexOf(name) > -1) {
return true;
}
return super.isRedeclaredInScope(...arguments);
}
checkLocalExport(id: N.Identifier) {
if (
this.scopeStack[0].types.indexOf(id.name) === -1 &&
this.scopeStack[0].exportOnlyBindings.indexOf(id.name) === -1
) {
super.checkLocalExport(id);
}
}
}

View File

@@ -9,17 +9,18 @@ import {
SCOPE_SUPER,
SCOPE_PROGRAM,
SCOPE_VAR,
BIND_SIMPLE_CATCH,
BIND_LEXICAL,
BIND_FUNCTION,
SCOPE_CLASS,
BIND_SCOPE_FUNCTION,
BIND_SCOPE_VAR,
BIND_SCOPE_LEXICAL,
BIND_KIND_VALUE,
type ScopeFlags,
type BindingTypes,
SCOPE_CLASS,
} from "./scopeflags";
import * as N from "../types";
// Start an AST node, attaching a start offset.
class Scope {
export class Scope {
flags: ScopeFlags;
// A list of var-declared names in the current lexical scope
var: string[] = [];
@@ -37,8 +38,8 @@ type raiseFunction = (number, string) => void;
// The functions in this module keep track of declared variables in the
// current scope in order to detect duplicate variable names.
export default class ScopeHandler {
scopeStack: Array<Scope> = [];
export default class ScopeHandler<IScope: Scope = Scope> {
scopeStack: Array<IScope> = [];
raise: raiseFunction;
inModule: boolean;
undefinedExports: Map<string, number> = new Map();
@@ -70,8 +71,14 @@ export default class ScopeHandler {
return this.treatFunctionsAsVarInScope(this.currentScope());
}
createScope(flags: ScopeFlags): Scope {
return new Scope(flags);
}
// This method will be overwritten by subclasses
+createScope: (flags: ScopeFlags) => IScope;
enter(flags: ScopeFlags) {
this.scopeStack.push(new Scope(flags));
this.scopeStack.push(this.createScope(flags));
}
exit() {
@@ -81,46 +88,33 @@ export default class ScopeHandler {
// The spec says:
// > At the top level of a function, or script, function declarations are
// > treated like var declarations rather than like lexical declarations.
treatFunctionsAsVarInScope(scope: Scope): boolean {
treatFunctionsAsVarInScope(scope: IScope): boolean {
return !!(
scope.flags & SCOPE_FUNCTION ||
(!this.inModule && scope.flags & SCOPE_PROGRAM)
);
}
declareName(name: string, bindingType: ?BindingTypes, pos: number) {
let redeclared = false;
declareName(name: string, bindingType: BindingTypes, pos: number) {
let scope = this.currentScope();
if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {
this.checkRedeclarationInScope(scope, name, bindingType, pos);
if (bindingType === BIND_LEXICAL) {
redeclared =
scope.lexical.indexOf(name) > -1 ||
scope.functions.indexOf(name) > -1 ||
scope.var.indexOf(name) > -1;
scope.lexical.push(name);
} else if (bindingType === BIND_SIMPLE_CATCH) {
scope.lexical.push(name);
} else if (bindingType === BIND_FUNCTION) {
if (this.treatFunctionsAsVar) {
redeclared = scope.lexical.indexOf(name) > -1;
if (bindingType & BIND_SCOPE_FUNCTION) {
scope.functions.push(name);
} else {
redeclared =
scope.lexical.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
scope.lexical.push(name);
}
scope.functions.push(name);
} else {
if (bindingType & BIND_SCOPE_LEXICAL) {
this.maybeExportDefined(scope, name);
}
} else if (bindingType & BIND_SCOPE_VAR) {
for (let i = this.scopeStack.length - 1; i >= 0; --i) {
scope = this.scopeStack[i];
if (
(scope.lexical.indexOf(name) > -1 &&
!(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name)) ||
(!this.treatFunctionsAsVarInScope(scope) &&
scope.functions.indexOf(name) > -1)
) {
redeclared = true;
break;
}
this.checkRedeclarationInScope(scope, name, bindingType, pos);
scope.var.push(name);
this.maybeExportDefined(scope, name);
if (scope.flags & SCOPE_VAR) break;
}
@@ -128,11 +122,56 @@ export default class ScopeHandler {
if (this.inModule && scope.flags & SCOPE_PROGRAM) {
this.undefinedExports.delete(name);
}
if (redeclared) {
}
maybeExportDefined(scope: IScope, name: string) {
if (this.inModule && scope.flags & SCOPE_PROGRAM) {
this.undefinedExports.delete(name);
}
}
checkRedeclarationInScope(
scope: IScope,
name: string,
bindingType: BindingTypes,
pos: number,
) {
if (this.isRedeclaredInScope(scope, name, bindingType)) {
this.raise(pos, `Identifier '${name}' has already been declared`);
}
}
isRedeclaredInScope(
scope: IScope,
name: string,
bindingType: BindingTypes,
): boolean {
if (!(bindingType & BIND_KIND_VALUE)) return false;
if (bindingType & BIND_SCOPE_LEXICAL) {
return (
scope.lexical.indexOf(name) > -1 ||
scope.functions.indexOf(name) > -1 ||
scope.var.indexOf(name) > -1
);
}
if (bindingType & BIND_SCOPE_FUNCTION) {
return (
scope.lexical.indexOf(name) > -1 ||
(!this.treatFunctionsAsVarInScope(scope) &&
scope.var.indexOf(name) > -1)
);
}
return (
(scope.lexical.indexOf(name) > -1 &&
!(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name)) ||
(!this.treatFunctionsAsVarInScope(scope) &&
scope.functions.indexOf(name) > -1)
);
}
checkLocalExport(id: N.Identifier) {
if (
this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
@@ -146,12 +185,12 @@ export default class ScopeHandler {
}
}
currentScope(): Scope {
currentScope(): IScope {
return this.scopeStack[this.scopeStack.length - 1];
}
// $FlowIgnore
currentVarScope(): Scope {
currentVarScope(): IScope {
for (let i = this.scopeStack.length - 1; ; i--) {
const scope = this.scopeStack[i];
if (scope.flags & SCOPE_VAR) {
@@ -162,7 +201,7 @@ export default class ScopeHandler {
// Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
// $FlowIgnore
currentThisScope(): Scope {
currentThisScope(): IScope {
for (let i = this.scopeStack.length - 1; ; i--) {
const scope = this.scopeStack[i];
if (

View File

@@ -35,18 +35,51 @@ export function functionFlags(isAsync: boolean, isGenerator: boolean) {
);
}
// Used in checkLVal and declareName to determine the type of a binding
export const BIND_NONE = 0, // Not a binding
BIND_VAR = 1, // Var-style binding
BIND_LEXICAL = 2, // Let- or const-style binding
BIND_FUNCTION = 3, // Function declaration
BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding
BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
// These flags are meant to be _only_ used inside the Scope class (or subclasses).
// prettier-ignore
export const BIND_KIND_VALUE = 0b00000_0000_01,
BIND_KIND_TYPE = 0b00000_0000_10,
// Used in checkLVal and declareName to determine the type of a binding
BIND_SCOPE_VAR = 0b00000_0001_00, // Var-style binding
BIND_SCOPE_LEXICAL = 0b00000_0010_00, // Let- or const-style binding
BIND_SCOPE_FUNCTION = 0b00000_0100_00, // Function declaration
BIND_SCOPE_OUTSIDE = 0b00000_1000_00, // Special case for function names as
// bound inside the function
// Misc flags
BIND_FLAGS_NONE = 0b00001_0000_00,
BIND_FLAGS_CLASS = 0b00010_0000_00,
BIND_FLAGS_TS_ENUM = 0b00100_0000_00,
BIND_FLAGS_TS_CONST_ENUM = 0b01000_0000_00,
BIND_FLAGS_TS_EXPORT_ONLY = 0b10000_0000_00;
// These flags are meant to be _only_ used by Scope consumers
// prettier-ignore
/* = is value? | is type? | scope | misc flags */
export const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_CLASS ,
BIND_LEXICAL = BIND_KIND_VALUE | 0 | BIND_SCOPE_LEXICAL | 0 ,
BIND_VAR = BIND_KIND_VALUE | 0 | BIND_SCOPE_VAR | 0 ,
BIND_FUNCTION = BIND_KIND_VALUE | 0 | BIND_SCOPE_FUNCTION | 0 ,
BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS ,
BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0 ,
BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM,
BIND_TS_FN_TYPE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,
// These bindings don't introduce anything in the scope. They are used for assignments and
// function expressions IDs.
BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE ,
BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE ,
BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM,
BIND_TS_NAMESPACE = BIND_TS_FN_TYPE;
export type BindingTypes =
| typeof BIND_NONE
| typeof BIND_OUTSIDE
| typeof BIND_VAR
| typeof BIND_LEXICAL
| typeof BIND_CLASS
| typeof BIND_FUNCTION
| typeof BIND_SIMPLE_CATCH
| typeof BIND_OUTSIDE;
| typeof BIND_TS_INTERFACE
| typeof BIND_TS_TYPE
| typeof BIND_TS_ENUM
| typeof BIND_TS_FN_TYPE
| typeof BIND_TS_NAMESPACE;