sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
76.8k stars 3.98k forks source link

Svelte 5: Auto completion implies that you can access state from another file even tho you cant #11473

Closed Raphael2b3 closed 1 week ago

Raphael2b3 commented 1 week ago

Describe the bug

My vscode shows me i have access to a $state-variable declared in another file even i didnt export and import it.

See the video

It mystate should not show up.

I am sry if this is the wrong place to post this issue.

Reproduction

run npm create svelte@latest -skeleton, svelte-5 preview

(I have noticed that this command installs "svelte": "^5.0.0-next.1" even tho there is ^5.0.0-next.123 already)

i have updated svelte via npm i -D svelte@next

https://github.com/sveltejs/svelte/assets/70175424/b40a5f14-fd5b-47b0-b82b-e7dea6c764d9

Logs

No response

System Info

`npx envinfo --system --npmPackages svelte,rollup,webpack --binaries --browsers` this command doesnt work on my machine but i think its not relevant.

I am on Win11 

package.json 
{
    "name": "compilerbug",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "dev": "vite dev",
        "build": "vite build",
        "preview": "vite preview",
        "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
        "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
    },
    "devDependencies": {
        "@sveltejs/adapter-auto": "^3.0.0",
        "@sveltejs/kit": "^2.0.0",
        "@sveltejs/vite-plugin-svelte": "^3.0.0",
        "svelte": "^5.0.0-next.123",
        "svelte-check": "^3.6.0",
        "tslib": "^2.4.1",
        "typescript": "^5.0.0",
        "vite": "^5.0.3"
    },
    "type": "module"
}

Severity

annoyance

Raphael2b3 commented 1 week ago

I just realized this is not an issue of svelte but of vscode in general. Maby svelte could add an extra check for it.

Raphael2b3 commented 1 week ago

closing because of wrong place to ask

dummdidumm commented 1 week ago

This happens because there are no imports or exports in that module, which means typescript treats all definitions inside it as globally available. I don't exactly remember why, but it's like that for some reason