Closed
Description
Describe the bug
When using typescript within .svelte files, the generated source map references the wrong line number, it is too low.
To Reproduce
- Checkout the template and install libraries:
npx degit sveltejs/template svelte-typescript-app
cd svelte-typescript-app
npm install
- Modify the script in
src/App.svelte
like this:
<script>
export let name;
// test comment
console.error("error logged from line five in App.svelte")
</script>
- Run the app and visit it in a browser, the following message is in the JavaScript console:
error logged from line five in App.svelte App.svelte:5
- Now add TypeScript support according to the instructions in the blog:
node scripts/setupTypeScript.js
npm install
- Mark the script in
src/App.svelte
as TypeScript:
<script lang="ts">
export let name;
// test comment
console.error("error logged from line five in App.svelte")
</script>
- Run the app, visit it again, find the following message in the browser console:
error logged from line five in App.svelte App.svelte:3
I've published a reproduction repo here: https://github.com/fd0/svelte-bug-typescript-sourcemap (including package-lock.json
).
Expected behavior
The error message should refer to the correct line in the source code (line 5 instead of line 3).
Information about your Svelte project:
- Chrome 83.0.4103.116
- Debian Buster
- Svelte 3.24.0
- Rollup 2.22.2
Severity
It's very annoying, but does not block me (or anybody else). Debugging takes much longer.
Additional context
Thank you very much for adding TypeScript to Svelte, I love it!
Metadata
Metadata
Assignees
Labels
No labels