Closed tomblachut closed 1 year ago
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 (...)
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.
Moving to WEB-62304 Svelte: improve local reference resolve
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.