Circular references cause errors with TypeScript preprocessing.
See original GitHub issueDescribe the bug
When creating components with circular references there are Typescript errors on the component usage and possibly script
tags. This happend when i created a menu consisting of a Menu
referencing a MenuItem
component, while the MenuItem
again references Menu
for the sub-menu entries.
The build still works just fine.
To Reproduce Steps to reproduce the behavior:
- Have component A which imports and uses component B.
- Have component B which imports and uses component A.
- Make scripts
type="text/typescript"
.
There may be this error on the script tag (probably only appears with no-implicit-any enabled, but the type not being resolved probably causes the errors at the component usage site):
‘render’ implicitly has return type ‘any’ because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.ts(7023)
And something like the following on the component usage:
JSX element class does not support attributes because it does not have a ‘$$prop_def’ property.ts(2607)
‘B’ cannot be used as a JSX component. Its instance type ‘B__SvelteComponent_’ is not a valid JSX element. Property ‘$$prop_def’ is missing in type ‘B__SvelteComponent_’ but required in type ‘ElementClass’.ts(2786)
(If i comment out one of the component usages, all errors disappear.)
Expected behavior No errors, if possible.
System (please complete the following information):
- OS: Windows 10 64bit
- IDE: VS Code 1.47.3
- Plugin/Package: Svelte for VSCode
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7 (4 by maintainers)
Top GitHub Comments
This should be possible to solve now with the new experimental
$$Events
interface, see #442 for more info@dummdidumm That appears to work, thanks! Of course a general fix would still be appreciated