Skip to content

Commit 7e32537

Browse files
authored
fix: ensure AST analysis on svelte.js modules succeeds (#15297)
This was the result of a `@ts-expect-error` silencing other type errors, which lead to this creeping in. This changes it so that the object is fully set, so we'll get type errors when new properties need to be added fixes #15284
1 parent 8b97725 commit 7e32537

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.changeset/good-spiders-own.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure AST analysis on `svelte.js` modules succeeds

packages/svelte/src/compiler/phases/2-analyze/index.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,20 @@ export function analyze_module(ast, options) {
258258
{
259259
scope,
260260
scopes,
261-
// @ts-expect-error TODO
262-
analysis
261+
analysis: /** @type {ComponentAnalysis} */ (analysis),
262+
derived_state: [],
263+
// TODO the following are not needed for modules, but we have to pass them in order to avoid type error,
264+
// and reducing the type would result in a lot of tedious type casts elsewhere - find a good solution one day
265+
ast_type: /** @type {any} */ (null),
266+
component_slots: new Set(),
267+
expression: null,
268+
function_depth: 0,
269+
has_props_rune: false,
270+
instance_scope: /** @type {any} */ (null),
271+
options: /** @type {ValidatedCompileOptions} */ (options),
272+
parent_element: null,
273+
reactive_statement: null,
274+
reactive_statements: new Map()
263275
},
264276
visitors
265277
);

0 commit comments

Comments
 (0)