From 7e3253745e3921d5718dce3ee5d5a9e72d471f58 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Sat, 15 Feb 2025 00:03:52 +0100 Subject: [PATCH] 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 --- .changeset/good-spiders-own.md | 5 +++++ .../src/compiler/phases/2-analyze/index.js | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .changeset/good-spiders-own.md diff --git a/.changeset/good-spiders-own.md b/.changeset/good-spiders-own.md new file mode 100644 index 0000000000..aacbda133e --- /dev/null +++ b/.changeset/good-spiders-own.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure AST analysis on `svelte.js` modules succeeds diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index 846abcf7df..93c438c852 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -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 );