UNPKG

4.62 kBTypeScriptView Raw
1import { TSESTree } from '../ts-estree';
2import { Definition } from './Definition';
3import { Reference, ReferenceFlag } from './Reference';
4import { ScopeManager } from './ScopeManager';
5import { Variable } from './Variable';
6declare type ScopeType = 'block' | 'catch' | 'class' | 'for' | 'function' | 'function-expression-name' | 'global' | 'module' | 'switch' | 'with' | 'TDZ' | 'enum' | 'empty-function';
7interface Scope {
8 type: ScopeType;
9 isStrict: boolean;
10 upper: Scope | null;
11 childScopes: Scope[];
12 variableScope: Scope;
13 block: TSESTree.Node;
14 variables: Variable[];
15 set: Map<string, Variable>;
16 references: Reference[];
17 through: Reference[];
18 thisFound?: boolean;
19 taints: Map<string, boolean>;
20 functionExpressionScope: boolean;
21 __left: Reference[];
22 __shouldStaticallyClose(scopeManager: ScopeManager): boolean;
23 __shouldStaticallyCloseForGlobal(ref: any): boolean;
24 __staticCloseRef(ref: any): void;
25 __dynamicCloseRef(ref: any): void;
26 __globalCloseRef(ref: any): void;
27 __close(scopeManager: ScopeManager): Scope;
28 __isValidResolution(ref: any, variable: any): variable is Variable;
29 __resolve(ref: Reference): boolean;
30 __delegateToUpperScope(ref: any): void;
31 __addDeclaredVariablesOfNode(variable: any, node: TSESTree.Node): void;
32 __defineGeneric(name: string, set: Map<string, Variable>, variables: Variable[], node: TSESTree.Identifier, def: Definition): void;
33 __define(node: TSESTree.Node, def: Definition): void;
34 __referencing(node: TSESTree.Node, assign?: ReferenceFlag, writeExpr?: TSESTree.Node, maybeImplicitGlobal?: any, partial?: any, init?: any): void;
35 __detectEval(): void;
36 __detectThis(): void;
37 __isClosed(): boolean;
38 /**
39 * returns resolved {Reference}
40 * @method Scope#resolve
41 * @param {Espree.Identifier} ident - identifier to be resolved.
42 * @returns {Reference} reference
43 */
44 resolve(ident: TSESTree.Node): Reference;
45 /**
46 * returns this scope is static
47 * @method Scope#isStatic
48 * @returns {boolean} static
49 */
50 isStatic(): boolean;
51 /**
52 * returns this scope has materialized arguments
53 * @method Scope#isArgumentsMaterialized
54 * @returns {boolean} arguments materialized
55 */
56 isArgumentsMaterialized(): boolean;
57 /**
58 * returns this scope has materialized `this` reference
59 * @method Scope#isThisMaterialized
60 * @returns {boolean} this materialized
61 */
62 isThisMaterialized(): boolean;
63 isUsedName(name: any): boolean;
64}
65interface ScopeConstructor {
66 new (scopeManager: ScopeManager, type: ScopeType, upperScope: Scope | null, block: TSESTree.Node | null, isMethodDefinition: boolean): Scope;
67}
68declare const Scope: ScopeConstructor;
69interface ScopeChildConstructorWithUpperScope<T> {
70 new (scopeManager: ScopeManager, upperScope: Scope, block: TSESTree.Node | null): T;
71}
72interface GlobalScope extends Scope {
73}
74declare const GlobalScope: ScopeConstructor & (new (scopeManager: ScopeManager, block: TSESTree.Node | null) => GlobalScope);
75interface ModuleScope extends Scope {
76}
77declare const ModuleScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<ModuleScope>;
78interface FunctionExpressionNameScope extends Scope {
79}
80declare const FunctionExpressionNameScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<FunctionExpressionNameScope>;
81interface CatchScope extends Scope {
82}
83declare const CatchScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<CatchScope>;
84interface WithScope extends Scope {
85}
86declare const WithScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<WithScope>;
87interface BlockScope extends Scope {
88}
89declare const BlockScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<BlockScope>;
90interface SwitchScope extends Scope {
91}
92declare const SwitchScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<SwitchScope>;
93interface FunctionScope extends Scope {
94}
95declare const FunctionScope: ScopeConstructor & (new (scopeManager: ScopeManager, upperScope: Scope, block: TSESTree.Node | null, isMethodDefinition: boolean) => FunctionScope);
96interface ForScope extends Scope {
97}
98declare const ForScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<ForScope>;
99interface ClassScope extends Scope {
100}
101declare const ClassScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<ClassScope>;
102export { ScopeType, Scope, GlobalScope, ModuleScope, FunctionExpressionNameScope, CatchScope, WithScope, BlockScope, SwitchScope, FunctionScope, ForScope, ClassScope, };
103//# sourceMappingURL=Scope.d.ts.map
\No newline at end of file