-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Description
Describe the bug
Hi ! I don't know if this is a bug or if this is intended but when I import a module in a page, I get an error if the module is a .ts file and I dont put a lang="ts in my <script>.
There's no TS syntax in the <script> or in the imported module.
Adding lang="ts" in the src/routes/+page.svelte <script> fixes the issue.
I usually put lang="ts in all my scripts but the autoimport feature in vscode creates a simple <script></script> if there are none so this took me some time to figure out
Reproduction
Here's a small reproduction repro : https://github.com/romaindurand/repro-svelte-ts-import-error
Logs
the svelte CLI configuration :
❯ npx sv create repro-svelte-ts-import-error
┌ Welcome to the Svelte CLI! (v0.6.1)
│
◇ Which template would you like?
│ SvelteKit minimal
│
◇ Add type checking with Typescript?
│ Yes, using Typescript syntax
│
◆ Project created
│
◇ What would you like to add to your project? (use arrow keys / space bar)
│ prettier, eslint
│
◇ Which package manager do you want to install dependencies with?
│ pnpm
│
◆ Successfully setup add-ons
│
◇ Successfully installed dependencies
│
◇ Successfully formatted modified files
│
◇ Project next steps ─────────────────────────────────────────────────────╮
│ │
│ 1: cd repro-svelte-ts-import-error │
│ 2: git init && git add -A && git commit -m "Initial commit" (optional) │
│ 3: pnpm dev --open │
│ │
│ To close the dev server, hit Ctrl-C │
│ │
│ Stuck? Visit us at https://svelte.dev/chat │
│ │
├──────────────────────────────────────────────────────────────────────────╯
│
└ You're all set!System Info
System:
OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
CPU: (8) x64 Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
Memory: 15.47 GB / 30.98 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
pnpm: 9.12.2 - ~/.local/share/pnpm/pnpm
Browsers:
Chrome: 129.0.6668.58
npmPackages:
svelte: ^5.0.0 => 5.1.12Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels
