1- import type {
2- ClassDeclaration ,
3- Expression ,
4- FunctionDeclaration ,
5- Identifier ,
6- ImportDeclaration
7- } from 'estree' ;
81import type { SourceMap } from 'magic-string' ;
9- import type { Scope } from '../phases/scope.js' ;
2+ import type { Binding } from '../phases/scope.js' ;
103import type { AST , Namespace } from './template.js' ;
114import type { ICompileDiagnostic } from '../utils/compile_diagnostic.js' ;
125
@@ -241,6 +234,20 @@ export type ValidatedCompileOptions = ValidatedModuleCompileOptions &
241234 hmr : CompileOptions [ 'hmr' ] ;
242235 } ;
243236
237+ export type BindingKind =
238+ | 'normal' // A variable that is not in any way special
239+ | 'prop' // A normal prop (possibly reassigned or mutated)
240+ | 'bindable_prop' // A prop one can `bind:` to (possibly reassigned or mutated)
241+ | 'rest_prop' // A rest prop
242+ | 'raw_state' // A state variable
243+ | 'state' // A deeply reactive state variable
244+ | 'derived' // A derived variable
245+ | 'each' // An each block parameter
246+ | 'snippet' // A snippet parameter
247+ | 'store_sub' // A $store value
248+ | 'legacy_reactive' // A `$:` declaration
249+ | 'template' ; // A binding declared in the template, e.g. in an `await` block or `const` tag
250+
244251export type DeclarationKind =
245252 | 'var'
246253 | 'let'
@@ -251,66 +258,6 @@ export type DeclarationKind =
251258 | 'rest_param'
252259 | 'synthetic' ;
253260
254- export interface Binding {
255- node : Identifier ;
256- /**
257- * - `normal`: A variable that is not in any way special
258- * - `prop`: A normal prop (possibly reassigned or mutated)
259- * - `bindable_prop`: A prop one can `bind:` to (possibly reassigned or mutated)
260- * - `rest_prop`: A rest prop
261- * - `state`: A state variable
262- * - `derived`: A derived variable
263- * - `each`: An each block parameter
264- * - `snippet`: A snippet parameter
265- * - `store_sub`: A $store value
266- * - `legacy_reactive`: A `$:` declaration
267- * - `template`: A binding declared in the template, e.g. in an `await` block or `const` tag
268- */
269- kind :
270- | 'normal'
271- | 'prop'
272- | 'bindable_prop'
273- | 'rest_prop'
274- | 'state'
275- | 'raw_state'
276- | 'derived'
277- | 'each'
278- | 'snippet'
279- | 'store_sub'
280- | 'legacy_reactive'
281- | 'template'
282- | 'snippet' ;
283- declaration_kind : DeclarationKind ;
284- /**
285- * What the value was initialized with.
286- * For destructured props such as `let { foo = 'bar' } = $props()` this is `'bar'` and not `$props()`
287- */
288- initial :
289- | null
290- | Expression
291- | FunctionDeclaration
292- | ClassDeclaration
293- | ImportDeclaration
294- | AST . EachBlock
295- | AST . SnippetBlock ;
296- is_called : boolean ;
297- references : { node : Identifier ; path : AST . SvelteNode [ ] } [ ] ;
298- mutated : boolean ;
299- reassigned : boolean ;
300- /** `true` if mutated _or_ reassigned */
301- updated : boolean ;
302- scope : Scope ;
303- /** For `legacy_reactive`: its reactive dependencies */
304- legacy_dependencies : Binding [ ] ;
305- /** Legacy props: the `class` in `{ export klass as class}`. $props(): The `class` in { class: klass } = $props() */
306- prop_alias : string | null ;
307- /** Additional metadata, varies per binding type */
308- metadata : {
309- /** `true` if is (inside) a rest parameter */
310- inside_rest ?: boolean ;
311- } | null ;
312- }
313-
314261export interface ExpressionMetadata {
315262 /** All the bindings that are referenced inside this expression */
316263 dependencies : Set < Binding > ;
@@ -322,5 +269,7 @@ export interface ExpressionMetadata {
322269
323270export * from './template.js' ;
324271
272+ export { Binding , Scope } from '../phases/scope.js' ;
273+
325274// TODO this chain is a bit weird
326275export { ReactiveStatement } from '../phases/types.js' ;
0 commit comments