@@ -28,7 +28,7 @@ const scopeManager = eslintScope.analyze(
2828
2929// $ExpectType GlobalScope
3030scopeManager . globalScope ;
31- // $ExpectType Scope<Variable<Reference>, Reference>[]
31+ // $ExpectType Scope<Variable<Reference>, Reference>[]
3232scopeManager . scopes ;
3333
3434// $ExpectType Scope<Variable<Reference>, Reference> | null
@@ -50,15 +50,15 @@ if (scope) {
5050 scope . variables ;
5151 // $ExpectType Reference[]
5252 scope . references ;
53- // $ExpectType Scope<Variable<Reference>, Reference>[]
53+ // $ExpectType Scope<Variable<Reference>, Reference>[]
5454 scope . childScopes ;
5555 // $ExpectType Node
5656 scope . block ;
5757 // $ExpectType boolean
5858 scope . functionExpressionScope ;
5959 // $ExpectType Reference[]
6060 scope . implicit . left ;
61- // $ExpectType Map<string, Variable>
61+ // $ExpectType Map<string, Variable>
6262 scope . set ;
6363 // $ExpectType Reference[]
6464 scope . through ;
@@ -109,3 +109,155 @@ globalScope.type;
109109
110110// $ExpectType ScopeManager
111111eslintScope . analyze ( ast ) ;
112+
113+ const blockScope = new eslintScope . BlockScope ( scopeManager , scopeManager . globalScope , ast ) ;
114+ // $ExpectType "block"
115+ blockScope . type ;
116+
117+ const identifier : estree . Identifier = {
118+ type : "Identifier" ,
119+ name : "foo" ,
120+ } ;
121+ const definition2 = new eslintScope . Definition (
122+ "Variable" ,
123+ identifier ,
124+ ast ,
125+ null ,
126+ null ,
127+ "let" ,
128+ ) ;
129+ // $ExpectType "CatchClause" | "TDZ" | "ClassName" | "FunctionName" | "ImplicitGlobalVariable" | "ImportBinding" | "Parameter" | "Variable"
130+ definition2 . type ;
131+ // $ExpectType Identifier
132+ definition2 . name ;
133+
134+ const functionScope = new eslintScope . FunctionScope ( scopeManager , scopeManager . globalScope , ast , false ) ;
135+ // $ExpectType "function"
136+ functionScope . type ;
137+ // $ExpectType boolean
138+ functionScope . isArgumentsMaterialized ( ) ;
139+ // $ExpectType boolean
140+ functionScope . isThisMaterialized ( ) ;
141+
142+ const globalScopeInstance = new eslintScope . GlobalScope ( scopeManager , ast ) ;
143+ // $ExpectType "global"
144+ globalScopeInstance . type ;
145+
146+ const moduleScope = new eslintScope . ModuleScope ( scopeManager , scopeManager . globalScope , ast ) ;
147+ // $ExpectType "module"
148+ moduleScope . type ;
149+
150+ const ref = new eslintScope . Reference (
151+ identifier ,
152+ scopeManager . globalScope ,
153+ 0 ,
154+ null ,
155+ false ,
156+ false ,
157+ false ,
158+ ) ;
159+ // $ExpectType Identifier
160+ ref . identifier ;
161+ // $ExpectType Scope<Variable<Reference>, Reference>
162+ ref . from ;
163+ // $ExpectType boolean
164+ ref . isRead ( ) ;
165+ // $ExpectType boolean
166+ ref . isWrite ( ) ;
167+ // $ExpectType boolean
168+ ref . isReadOnly ( ) ;
169+ // $ExpectType boolean
170+ ref . isWriteOnly ( ) ;
171+ // $ExpectType boolean
172+ ref . isReadWrite ( ) ;
173+
174+ const scopeInstance = new eslintScope . Scope (
175+ scopeManager ,
176+ "block" ,
177+ null ,
178+ ast ,
179+ false ,
180+ ) ;
181+ // $ExpectType "function" | "module" | "block" | "catch" | "class" | "for" | "function-expression-name" | "global" | "switch" | "with" | "TDZ"
182+ scopeInstance . type ;
183+ // $ExpectType boolean
184+ scopeInstance . isStrict ;
185+ // $ExpectType Scope<Variable<Reference>, Reference> | null
186+ scopeInstance . upper ;
187+ // $ExpectType Scope<Variable<Reference>, Reference>
188+ scopeInstance . variableScope ;
189+ // $ExpectType Variable<Reference>[]
190+ scopeInstance . variables ;
191+ // $ExpectType Reference[]
192+ scopeInstance . references ;
193+ // $ExpectType Scope<Variable<Reference>, Reference>[]
194+ scopeInstance . childScopes ;
195+ // $ExpectType Node
196+ scopeInstance . block ;
197+ // $ExpectType boolean
198+ scopeInstance . functionExpressionScope ;
199+ // $ExpectType { left: Reference[]; set: Map<string, Variable<Reference>>; }
200+ scopeInstance . implicit ;
201+ // $ExpectType Map<string, Variable>
202+ scopeInstance . set ;
203+ // $ExpectType Map<string, Variable<Reference>>
204+ scopeInstance . taints ;
205+ // $ExpectType Reference[]
206+ scopeInstance . through ;
207+ // $ExpectType boolean
208+ scopeInstance . dynamic ;
209+ // $ExpectType boolean
210+ scopeInstance . directCallToEvalScope ;
211+ // $ExpectType boolean
212+ scopeInstance . thisFound ;
213+ // $ExpectType void
214+ scopeInstance . resolve ( ref ) ;
215+ // $ExpectType boolean
216+ scopeInstance . isStatic ( ) ;
217+ // $ExpectType boolean
218+ scopeInstance . isArgumentsMaterialized ( ) ;
219+ // $ExpectType boolean
220+ scopeInstance . isThisMaterialized ( ) ;
221+ // $ExpectType boolean
222+ scopeInstance . isUsedName ( "foo" ) ;
223+
224+ const scopeManagerInstance = new eslintScope . ScopeManager ( {
225+ ecmaVersion : 2022 ,
226+ sourceType : "module" ,
227+ } ) ;
228+ // $ExpectType GlobalScope
229+ scopeManagerInstance . globalScope ;
230+ // $ExpectType Scope<Variable<Reference>, Reference>[]
231+ scopeManagerInstance . scopes ;
232+ // $ExpectType Scope<Variable<Reference>, Reference> | null
233+ scopeManagerInstance . acquire ( ast ) ;
234+ // $ExpectType Scope<Variable<Reference>, Reference>[] | null
235+ scopeManagerInstance . acquireAll ( ast ) ;
236+ // $ExpectType Scope<Variable<Reference>, Reference> | null
237+ scopeManagerInstance . release ( ast ) ;
238+ // $ExpectType Variable<Reference>[]
239+ scopeManagerInstance . getDeclaredVariables ( ast ) ;
240+ // $ExpectType boolean
241+ scopeManagerInstance . isGlobalReturn ( ) ;
242+ // $ExpectType boolean
243+ scopeManagerInstance . isModule ( ) ;
244+ // $ExpectType boolean
245+ scopeManagerInstance . isImpliedStrict ( ) ;
246+ // $ExpectType boolean
247+ scopeManagerInstance . isStrictModeSupported ( ) ;
248+
249+ const variableInstance = new eslintScope . Variable ( "foo" , scopeInstance ) ;
250+ // $ExpectType string
251+ variableInstance . name ;
252+ // $ExpectType Scope<Variable<Reference>, Reference>
253+ variableInstance . scope ;
254+ // $ExpectType Identifier[]
255+ variableInstance . identifiers ;
256+ // $ExpectType Reference[]
257+ variableInstance . references ;
258+ // $ExpectType Definition[]
259+ variableInstance . defs ;
260+ // $ExpectType boolean
261+ variableInstance . tainted ;
262+ // $ExpectType boolean
263+ variableInstance . stack ;
0 commit comments