Skip to content

vscode does not recognize .svelte files imported in .ts files #1725

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

Closed
DetachHead opened this issue Nov 21, 2022 · 11 comments
Closed

vscode does not recognize .svelte files imported in .ts files #1725

DetachHead opened this issue Nov 21, 2022 · 11 comments
Labels
bug Something isn't working

Comments

@DetachHead
Copy link
Contributor

Describe the bug

i'm not quite sure it's even supposed to be allowed, but i stumbled across a project that has lots of .ts files importing .svelte files that seem to work at runtime, but not in vscode.

i suspect it's because it's using the typescript language server instead of the svelte one?

Reproduction

<!-- +page.svelte -->
<script lang="ts">
    export const a = 1
</script>
import { a } from './+page.svelte'

Expected behaviour

no error

System Info

  • OS: [e.g. Windows]
  • IDE: [e.g. VSCode, Atom]

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

image

@DetachHead DetachHead added the bug Something isn't working label Nov 21, 2022
@dummdidumm
Copy link
Member

Did you enable the Svelte TypeScript plugin? The vs code setting is called svelte.enable-ts-plugin

@DetachHead
Copy link
Contributor Author

yeah that's set to true

@ngmunyong
Copy link

I had the same issue until I realised I didn't add that vs code setting json in the project.

  1. create .vscode folder at project root
  2. add the line mentioned above

Screen Shot 2022-11-22 at 10 29 54 pm

Hope this works for you.

@DetachHead
Copy link
Contributor Author

still doesn't seem to work. also how come your .vscode folder is inside your .svelte-kit folder?

@hangilc
Copy link

hangilc commented Dec 18, 2022

I have encountered the same problem, and changing the TypeScript version through Cmd-Shift-P "TypeScript: Select TypeScript version..." to version 4.9.3 ('Use Workspace version' in my case) solved the problem. Before changing it has been set to 5.0.0-dev20221217 ('Use VS Code's Version').

@DetachHead
Copy link
Contributor Author

@hangilc doesn't fix it for me

@jasonlyu123
Copy link
Member

jasonlyu123 commented Dec 19, 2022

I can reproduce what @hangilc is seeing. One of the TypeScript APIs we used in the TypeScript plugin no longer works the same in ts 5.0. @DetachHead if you follow what @hangilc said, what's the version you're seeing in the "Use VS Code's Version" option? If it's not TypeScript 5.x. We'll need a reproduction repository. I can't reproduce it with your steps.

@DetachHead
Copy link
Contributor Author

hmm, now i can't get it to happen anymore. i'll close this issue for now and will re-open and try to provide a repro repo if it happens again. thanks

@DetachHead DetachHead closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2022
@dummdidumm
Copy link
Member

@jasonlyu123 would you open a PR to fix the plugin for upcoming TS 5.x? Is it possible to do this in a backwards-compatible way?

@DetachHead
Copy link
Contributor Author

if it doesn't work in 5.x, i'll reopen this

@DetachHead DetachHead reopened this Jan 4, 2023
@dummdidumm
Copy link
Member

I assume this was fixed, therefore closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants