sveltejs / template

Template for building basic applications with Svelte
1.74k stars 810 forks source link

"Cannot find module './App.svelte' " obscures actual errors/warnings during TypeScript development #218

Open mizzao opened 3 years ago

mizzao commented 3 years ago

Thanks for putting together this template, it's been very helpful, especially with TypeScript.

I have been running into a pretty annoying tooling problem where type errors or warnings deep in the app manifest as Cannot find module './App.svelte' during the build process. Here it is just a warning and the build proceeds, but sometimes it's an error that requires randomly trying a bunch of different things to fix. I believe it's probably TypeScript specific because a few times this happened, it's usually had to do with an import type statement that should have been an import or vice versa (in a different file), and this made the Cannot find module in main.ts go away.

image

If helpful, I think I could reproduce some of these situations from the original repo, but wanted to ask first in case there was an easy fix to get the underlying type errors to show up. I've been able to work around this mostly by relying on VSC's TypeScript intellisense, which catches errors in individual files, but sometimes the project build produces a different error that does not show up, and then I get stuck.

I might be doing something stupid here so please feel free to point out. Otherwise, happy to help debug this in any way that's helpful.

mizzao commented 3 years ago

Some additional info: I just re-read https://svelte.dev/blog/svelte-and-typescript, and saw the section about svelte-check. Running svelte-check shows hundreds of errors on the repo, but it seems almost all of them are either just TypeScript warnings, or a failure to understand Tailwind syntax:

image

If these errors could show up in the main build process (and skip the ones about Tailwind), that would be incredible. Happy to contribute to language tooling in any way I can; I imagine that the combination of Svelte+TS+Tailwind is pretty novel, but clearly very powerful once everything is working. Please let me know!