Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no error when importing non-existent .svelte file #1444

Closed
DetachHead opened this issue Apr 12, 2022 · 2 comments
Closed

no error when importing non-existent .svelte file #1444

DetachHead opened this issue Apr 12, 2022 · 2 comments
Labels
feature request New feature or request Fixed Fixed in master branch. Pending production release.

Comments

@DetachHead
Copy link
Contributor

DetachHead commented Apr 12, 2022

Describe the bug

when a .svelte file doesn't exist, no error is reported by svelte-check or by vscode

Reproduction

<script lang="ts">
    import Foo from 'Foo.svelte' //non-existent file
</script>

<main>
    <Foo />
</main>

Logs

> svelte-check --tsconfig ./tsconfig.json


====================================
Loading svelte-check in workspace: c:\Users\amogus\network-chungus
Getting Svelte diagnostics...

====================================
svelte-check found 0 errors, 0 warnings, and 0 hints

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (6) x64 Intel(R) Core(TM) i5-8600 CPU @ 3.10GHz
    Memory: 1.79 GB / 15.78 GB
  Binaries:
    Node: 16.9.1 - C:\Program Files\nodejs\node.EXE     
    npm: 7.24.1 - C:\Program Files\nodejs\npm.CMD       
  Browsers:
    Chrome: 99.0.4844.84
    Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.55)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    svelte: ^3.47.0 => 3.47.0

Severity

annoyance

@Conduitry Conduitry transferred this issue from sveltejs/svelte Apr 12, 2022
@jasonlyu123 jasonlyu123 added the feature request New feature or request label Apr 12, 2022
@dummdidumm
Copy link
Member

dummdidumm commented Apr 13, 2022

The problem is the

declare module "*.svelte";

definition inside Svelte core, which tells TS to treat every file ending with .svelte as if it exists. It can't be removed because people would get errors for all their Svelte file imports inside TypeScript files if they don't enable the TS plugin. I'm not sure how to make the diagnostic errors appear in another way. If there was a way to somehow ignore/exclude that ambient file definition (we know where inside the Svelte package it is located) that could be a way to do it - but it won't work using tsconfig.json's exclude setting because the ambient file is part of the Svelte file definition. We would have to remove it from the list of our files in the SnapshotManager maybe. We would also need to remove our similar module declaration inside svelte2tsx

dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Apr 13, 2022
Detect that an import of a .svelte file is pointing to a non-existent file by removing the ambient module definitions in svelte and svelte2tsx from the eyes of TS
sveltejs#1444
@DetachHead
Copy link
Contributor Author

It can't be removed because people would get errors for all their Svelte file imports inside TypeScript files if they don't enable the TS plugin.

is there a good reason to be using typescript without also using the plugin though? that just sounds to me like their project isn't set up correctly

dummdidumm added a commit that referenced this issue Apr 14, 2022
Detect that an import of a .svelte file is pointing to a non-existent file by removing the ambient module definitions in svelte and svelte2tsx from the eyes of TS
#1444
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

3 participants