From a482899bde0f71a0a37524fcf85274f228982724 Mon Sep 17 00:00:00 2001 From: Paolo Ricciuti Date: Tue, 25 Feb 2025 00:18:04 +0100 Subject: [PATCH] chore: add comments --- .../svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts index a0a4cbe67..d6f0ebdf6 100644 --- a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts +++ b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts @@ -93,6 +93,7 @@ export function processInstanceScriptContent( let scope = new Scope(); const rootScope = scope; + //track is the variable declared as `props` comes from `$props()` let isPropsDeclarationRune = false; const pushScope = () => (scope = new Scope(scope)); @@ -130,6 +131,7 @@ export function processInstanceScriptContent( return; } + //if we are in a variable declaration and the identifier is `props` we check the initializer if ( ident.text === 'props' && variableDeclarationNode && @@ -327,6 +329,7 @@ export function processInstanceScriptContent( //resolve stores if (isPropsDeclarationRune) { + //we filter out every pendingStore resolution that `isPropsId` if the variable names `props` comes from `$props()` pendingStoreResolutions = pendingStoreResolutions.filter(({ isPropsId }) => !isPropsId); } pendingStoreResolutions.map(resolveStore);