vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.6k stars 6.19k forks source link

When importing wrong local files shows no error. #18065

Open OlegBrony opened 2 months ago

OlegBrony commented 2 months ago

Describe the bug

First, I feel like it should be a known issue, but I can't find it anywhere in issues or SO etc. but i refuse to believe I'm the only one who bring this app.

When I change import file I expect IDE to highlight the error - because the file does not exist. but instead there is no error about import. it reproduces with all files except ts, tsx. Reproduce: 1) go here - https://stackblitz.com/edit/vitejs-vite-gzxywq?file=src%2Fmain.ts 2) check 3 and 4 lines.

image

I think it's related to this file /node_modules/vite/client.d.ts. in there are declared modules with specific files. maybe it should be written differently? or is it just me?

Reproduction

https://stackblitz.com/edit/vitejs-vite-gzxywq?file=src%2Fmain.ts

Steps to reproduce

No response

System Info

❯ npx envinfo --system --npmPackages '{vite,@vitejs/*,rollup}' --binaries --browsers
Need to install the following packages:
envinfo@7.13.0
Ok to proceed? (y) y

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^5.4.3 => 5.4.3

Used Package Manager

npm

Logs

No response

Validations

stackblitz[bot] commented 2 months ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

sapphi-red commented 2 months ago

TypeScript does not give us an easy way to do this: https://github.com/microsoft/TypeScript/issues/40450 I guess it's possible to achieve this by writing a TypeScript plugin. But using a plugin has some UX issues too.

OlegBrony commented 2 months ago

TypeScript does not give us an easy way to do this: microsoft/TypeScript#40450 I guess it's possible to achieve this by writing a TypeScript plugin. But using a plugin has some UX issues too.

so you say, that this is typescript related issue, not vite?

sapphi-red commented 2 months ago

Yes. It cannot be solved by changing a code in this repository. A change to TypeScript or, making a TypeScript plugin is required.