Skip to content

Svelte warning (unused export) displayed at wrong line since switching to typescript #333

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
dominic-simplan opened this issue Jul 23, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@dominic-simplan
Copy link

dominic-simplan commented Jul 23, 2020

Describe the bug
I have just switched my svelte project from js to typescript. Since then, a warning about an unused export is displayed at the wrong line.

I don't actually know if this is caused by the language-tools or if I should open this somewhere else?

Expected behavior
Warning should be displayed for the correct line.

Screenshots
grafik

First lines of the component:

<script lang="ts">
    import * as d3 from "d3";
    import * as formatDe from "d3-format/locale/de-DE.json";
    import { createEventDispatcher } from "svelte";

    export const NodeDetailsEvent = Object.freeze({
        LINK_EMPHASIZE: "linkEmphasize",
    });

    const dispatch = createEventDispatcher();

    export let width = "100%";
    export let height = "200px";
    export let responsive = false;
    export let selectedNode;

System (please complete the following information):

  • OS: Windows 10
  • IDE: VSCode 1.47.2
  • Plugin/Package: "Svelte for VSCode"
"svelte": "^3.22.3",
"svelte-check": "^0.1.55",
"svelte-loader": "^2.13.6",
"svelte-preprocess": "^4.0.8",
"typescript": "^3.9.7",
@dominic-simplan dominic-simplan added the bug Something isn't working label Jul 23, 2020
@jasonlyu123
Copy link
Member

Can you check if your tsconfig has sourcemap: false?

@dominic-simplan
Copy link
Author

dominic-simplan commented Jul 23, 2020

It doesn't, this is my tsconfig.json:

{
    "extends": "@tsconfig/svelte/tsconfig.json",
    "include": [
        "src/**/*",
        "src/node_modules"
    ],
    "exclude": [
        "node_modules/*",
        "dist/*"
    ],
    "compilerOptions": {
        "strict": false,
        "resolveJsonModule": true
    }
}

@dominic-simplan
Copy link
Author

After adding "sourceMap": true to my tsconfig, it seems that the correct line is underlined, even though I wonder why it doesn't underline the whole line.

grafik

So is this the expected behaviour? If yes, maybe the sourceMap option could be added to the tsconfig in the blog post?

@jasonlyu123
Copy link
Member

The problem is that if the preprocessed script doesn't have a sourcemap the warning would be targeting the transpiled javascript. @orta what do you think, should it default in the @tsconfig module?

@orta
Copy link
Contributor

orta commented Jul 28, 2020

We should!

@dummdidumm
Copy link
Member

"sourceMap": true now part of the base config.

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

4 participants