question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Circular references cause errors with TypeScript preprocessing.

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dummdidummcommented, Jul 5, 2021

This should be possible to solve now with the new experimental $$Events interface, see #442 for more info

1reaction
brunnerhcommented, Nov 13, 2020

@dummdidumm That appears to work, thanks! Of course a general fix would still be appreciated

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix nasty circular dependency issues once and for all in ...
Luckily, as I will demonstrate below, there is a consistent way in which these dependency issues can be fixed. The case. The module...
Read more >
Changelog - Cypress Documentation
Fixed an issue where an unhandled promise rejection would display an incomplete error message in the command log. Fixes #24915.
Read more >
When does a type "circular reference itself"? - Stack Overflow
The reason why the typescript compiler said your code was circular instead of that it used rest on the nonarray type Item is...
Read more >
The reasons I don't use Typescript - DEV Community ‍ ‍
At my first few programming jobs I worked on Java projects. It is here that I first learned to appreciate, but also hate...
Read more >
Pro Typescript18691606049810413.pdf
These are the problems that TypeScript solves. Because JavaScript has a C-like syntax, it looks familiar to a great many programmers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found