svelte-intellij icon indicating copy to clipboard operation
svelte-intellij copied to clipboard

Handle $$props etc variable shadowing

Open tomblachut opened this issue 3 years ago • 2 comments

https://svelte.dev/repl/1e78f2cd120247a9899d3a525675c836?version=3.24.1

Such variables need to be checked after reaching script tag, right now they are checked - by name - at the very beginning of reference resolving.

tomblachut avatar Aug 16 '20 11:08 tomblachut

I think this is a bug in Svelte itself to allow it, if we put this on the main scope, e.g.

const {name: $$props} = cats[0];

The compiler will complain The $ prefix is reserved, and cannot be used for variable and import names (...)

shirotech avatar Aug 18 '20 14:08 shirotech

But if you create event handler with $$props: Event as an argument, will it complain? I think not.

My current understanding is that this code

        implicitIdentifiers.forEach {
            if (JSSymbolUtil.isAccurateReferenceExpressionName(expression, it)) {
                val element = JSImplicitElementImpl.Builder(it, expression)
                    .forbidAstAccess()
                    .setType(JSImplicitElement.Type.Variable)
                    .setProperties(JSImplicitElement.Property.Constant)
                    .toImplicitElement()
                return arrayOf(JSResolveResult(element))
            }
        }

should be adapted and placed in SvelteHtmlFile#processDeclarations, after processing both script tags.

tomblachut avatar Aug 18 '20 15:08 tomblachut

Moving to WEB-62304 Svelte: improve local reference resolve

tomblachut avatar Aug 01 '23 18:08 tomblachut