Skip to content

Commit

Permalink
fix: ensure AST analysis on svelte.js modules succeeds
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dummdidumm committed Feb 14, 2025
1 parent b6bf735 commit 4da65c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-spiders-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure AST analysis on `svelte.js` modules succeeds
16 changes: 14 additions & 2 deletions packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,20 @@ export function analyze_module(ast, options) {
{
scope,
scopes,
// @ts-expect-error TODO
analysis
analysis: /** @type {ComponentAnalysis} */ (analysis),
derived_state: [],
// TODO the following are not needed for modules, but we have to pass them in order to avoid type error,
// and reducing the type would result in a lot of tedious type casts elsewhere - find a good solution one day
ast_type: /** @type {any} */ (null),
component_slots: new Set(),
expression: null,
function_depth: 0,
has_props_rune: false,
instance_scope: /** @type {any} */ (null),
options: /** @type {ValidatedCompileOptions} */ (options),
parent_element: null,
reactive_statement: null,
reactive_statements: new Map()
},
visitors
);
Expand Down

0 comments on commit 4da65c5

Please sign in to comment.