sveltejs / language-tools

The Svelte Language Server, and official extensions which use it
MIT License
1.26k stars 200 forks source link

`svelte-check` does not seem to include `.svelte-kit/tsconfig.json` on 4.0.1 + 4.0.0? #2485

Closed rbozan closed 2 months ago

rbozan commented 2 months ago

Describe the bug

On svelte-check 4.0.1:


game on  main [!] via  v20.15.1 via ❄️  impure (nix-shell-env) 
❯ npm install svelte-check@4.0.1  

added 2 packages, removed 5 packages, changed 2 packages, and audited 2028 packages in 2s

297 packages are looking for funding
  run `npm fund` for details

8 vulnerabilities (2 moderate, 6 high)

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

game on  main [!] via  v20.15.1 via ❄️  impure (nix-shell-env) took 2s 
❯ npm run check                 

> game@1.98.1 check
> svelte-kit sync && svelte-check --tsconfig ./tsconfig.json

====================================
Loading svelte-check in workspace: /home/rbozan/Projects/learning/game-group/game
Getting Svelte diagnostics...

/home/rbozan/Projects/learning/game-group/game/tsconfig.json:1:1
Error: No svelte input files were found in config file '/home/rbozan/Projects/learning/game-group/game/tsconfig.json'. Did you forget to add svelte files to the 'include' in your tsconfig.json? Specified 'include' paths were '["./src/gtag.d.ts","../generated/*.ts"]' and 'exclude' paths were '[".svelte-kit/../node_modules/**",".svelte-kit/../src/service-worker.js",".svelte-kit/../src/service-worker/**/*.js",".svelte-kit/../src/service-worker.ts",".svelte-kit/../src/service-worker/**/*.ts",".svelte-kit/../src/service-worker.d.ts",".svelte-kit/../src/service-worker/**/*.d.ts"]' (svelte)

====================================
svelte-check found 1 error and 0 warnings in 1 file

Reproduction

❯ npm run check                   

> game@1.98.1 check
> svelte-kit sync && svelte-check --tsconfig ./tsconfig.json

Expected behaviour

On svelte-check 3.8.5 it does seem to work:

❯ npm run check                   

> game@1.98.1 check
> svelte-kit sync && svelte-check --tsconfig ./tsconfig.json

====================================
Loading svelte-check in workspace: /home/rbozan/Projects/learning/game-group/game
Getting Svelte diagnostics...

====================================
svelte-check found 0 errors and 0 warnings

System Info

❯ npx envinfo --system  --npmPackages

  System:
    OS: Linux 6.6 NixOS 24.05 (Uakari) 24.05 (Uakari)
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i9-13900H
    Memory: 21.07 GB / 30.98 GB
    Container: Yes
    Shell: 5.9 - /run/current-system/sw/bin/zsh
  npmPackages:
    @auth/sveltekit: ^1.4.2 => 1.4.2 
    @ethercorps/sveltekit-og: ^3.0.0 => 3.0.0 
    @fontsource-variable/lexend: 5.0.21 => 5.0.21 
    @fontsource-variable/literata: ^5.0.22 => 5.0.22 
    @fontsource/overpass: 5.0.19 => 5.0.19 
    @fontsource/source-code-pro: 5.0.19 => 5.0.19 
    @graphql-codegen/cli: 5.0.2 => 5.0.2 
    @graphql-codegen/typed-document-node: 5.0.9 => 5.0.9 
    @graphql-codegen/typescript: 4.0.9 => 4.0.9 
    @graphql-codegen/typescript-operations: 4.2.3 => 4.2.3 
    @graphql-codegen/typescript-resolvers: 4.2.1 => 4.2.1 
    @graphql-codegen/urql-introspection: 3.0.0 => 3.0.0 
    @graphql-eslint/eslint-plugin: ^3.20.1 => 3.20.1 
    @inlang/paraglide-js: 1.11.2 => 1.11.2 
    @inlang/paraglide-js-adapter-sveltekit: ^0.6.7 => 0.6.7 
    @neoconfetti/svelte: 2.2.1 => 2.2.1 
    @playwright/test: ^1.46.1 => 1.46.1 
    @poppanator/sveltekit-svg: ^4.2.1 => 4.2.1 
    @popperjs/core: 2.11.8 => 2.11.8 
    @resvg/resvg-js: ^2.6.2 => 2.6.2 
    @semantic-release/changelog: ^6.0.3 => 6.0.3 
    @semantic-release/commit-analyzer: ^13.0.0 => 13.0.0 
    @semantic-release/git: ^10.0.1 => 10.0.1 
    @semantic-release/gitlab: ^13.2.1 => 13.2.1 
    @semantic-release/release-notes-generator: ^14.0.1 => 14.0.1 
    @sentry/sveltekit: ^8.28.0 => 8.28.0 
    @stripe/stripe-js: ^4.4.0 => 4.4.0 
    @sveltejs/adapter-auto: ^3.2.4 => 3.2.4 
    @sveltejs/adapter-node: ^5.2.2 => 5.2.2 
    @sveltejs/adapter-static: ^3.0.4 => 3.0.4 
    @sveltejs/kit: ^2.5.26 => 2.5.26 
    @sveltejs/vite-plugin-svelte: ^3.1.2 => 3.1.2 
    @sveltekit-addons/document: 1.0.1 => 1.0.1 
    @threlte/core: ^7.3.1 => 7.3.1 
    @threlte/extras: ^8.11.5 => 8.11.5 
    @types/cookie: 0.6.0 => 0.6.0 
    @types/diff: 5.2.2 => 5.2.2 
    @types/dom-speech-recognition: 0.0.4 => 0.0.4 
    @types/gtag.js: 0.0.20 => 0.0.20 
    @types/matter-js: ^0.19.7 => 0.19.7 
    @typescript-eslint/eslint-plugin: 8.4.0 => 8.4.0 
    @typescript-eslint/parser: 8.4.0 => 8.4.0 
    @urql/exchange-graphcache: ^7.1.2 => 7.1.2 
    @urql/exchange-retry: 1.3.0 => 1.3.0 
    @urql/svelte: ^4.2.1 => 4.2.1 
    @vite-pwa/assets-generator: ^0.2.6 => 0.2.6 
    @vite-pwa/sveltekit: ^0.6.2 => 0.6.5 
    @zerodevx/svelte-toast: ^0.9.5 => 0.9.5 
    autoprefixer: 10.4.20 => 10.4.20 
    camera-controls: ^2.9.0 => 2.9.0 
    chart.js: 4.4.4 => 4.4.4 
    chartjs-plugin-datalabels: 2.2.0 => 2.2.0 
    classnames: 2.5.1 => 2.5.1 
    countup.js: ^2.8.0 => 2.8.0 
    css-tree: ^2.3.1 => 2.3.1 
    curvereduce: ^1.0.0 => 1.0.0 
    dexie: 4.0.8 => 4.0.8 
    diff: 6.0.0 => 6.0.0 
    dragdroptouch: github:Bernardo-Castilho/dragdroptouch#d449e82a3e5dc59588fe4c4c4a5dde8f7a3afa7e => 1.0.0 
    driver.js: ^1.3.1 => 1.3.1 
    emoji-picker-element: ^1.22.4 => 1.22.4 
    eslint: ^9.9.1 => 9.9.1 
    eslint-config-prettier: 9.1.0 => 9.1.0 
    eslint-plugin-prettier: 5.2.1 => 5.2.1 
    eslint-plugin-simple-import-sort: 12.1.1 => 12.1.1 
    eslint-plugin-svelte: 2.43.0 => 2.43.0 
    eslint-plugin-unused-imports: ^4.1.3 => 4.1.3 
    firebase: ^10.13.1 => 10.13.1 
    fisher-yates: 1.0.4 => 1.0.4 
    flowbite: ^2.5.1 => 2.5.1 
    flowbite-svelte: ^0.46.16 => 0.46.16 
    ga-gtag: 1.2.0 => 1.2.0 
    graphql-codegen: 0.4.0 => 0.4.0 
    html-svelte-parser: ^1.0.0 => 1.0.0 
    i18n-iso-countries: ^7.11.3 => 7.11.3 
    intl-parse-accept-language: ^1.0.0 => 1.0.0 
    kolorist: 1.8.0 => 1.8.0 
    leaflet: 1.9.4 => 1.9.4 
    license-checker-rseidelsohn: 4.4.1 => 4.4.1 
    lottie-svelte: ^1.3.7 => 1.3.7 
    lucide-svelte: ^0.438.0 => 0.438.0 
    matter-js: ^0.20.0 => 0.20.0 
    media-chrome: ^4.1.0 => 4.1.0 
    meilisearch: ^0.42.0 => 0.42.0 
    moment: 2.30.1 => 2.30.1 
    pixi.js: 8.3.4 => 8.3.4 
    postcss: 8.4.45 => 8.4.45 
    postcss-load-config: 6.0.1 => 6.0.1 
    prettier: 3.3.3 => 3.3.3 
    prettier-plugin-svelte: 3.2.6 => 3.2.6 
    rollup-plugin-visualizer: 5.12.0 => 5.12.0 
    semantic-release: ^24.1.0 => 24.1.0 
    stripe: ^16.9.0 => 16.9.0 
    svelte: 4.2.19 => 4.2.19 
    svelte-chartjs: ^3.1.5 => 3.1.5 
    svelte-check: ^4.0.1 => 4.0.1 
    svelte-gestures: 5.0.4 => 5.0.4 
    svelte-inview: ^4.0.2 => 4.0.2 
    svelte-leafletjs: 1.2.0 => 1.2.0 
    svelte-persisted-store: ^0.11.0 => 0.11.0 
    svelte-portal: ^2.2.1 => 2.2.1 
    svelte-preprocess: ^6.0.2 => 6.0.2 
    svelte-rough-notation: ^0.1.5 => 0.1.5 
    svelte-typewriter: ^3.2.3 => 3.2.3 
    sveltekit-i18n: 2.4.2 => 2.4.2 
    svg-dom-arrows: 2.3.0 => 2.3.0 
    tailwindcss: 3.4.10 => 3.4.10 
    tesseract.js: 5.1.1 => 5.1.1 
    three: ^0.168.0 => 0.168.0 
    tslib: 2.7.0 => 2.7.0 
    typescript: 5.5.4 => 5.5.4 
    vanilla-cookieconsent: ^3.0.1 => 3.0.1 
    vite: ^5.4.3 => 5.4.3 
    vite-plugin-top-level-await: 1.4.4 => 1.4.4 
    vitest: ^2.0.5 => 2.0.5 
    wavesurfer.js: ^7.8.4 => 7.8.4 
    youtube-video-element: 1.1.6 => 1.1.6 

Which package is the issue about?

svelte-check

Additional Information, eg. Screenshots

My tsconfig.json:

{
  "extends": "./.svelte-kit/tsconfig.json",
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "types": [
      "vite-plugin-pwa/pwa-assets"
    ]
  },
  "include": [
    "./src/gtag.d.ts",
    "../generated/*.ts"
  ]
  // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
  //
  // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
  // from the referenced tsconfig.json - TypeScript does not merge them in
}

The generated .svelte-kit/tsconfig.json from the sync command:

{
    "compilerOptions": {
        "paths": {
            "@generated": [
                "../generated"
            ],
            "@generated/*": [
                "../generated/*"
            ],
            "$msgs": [
                "../src/lib/paraglide/messages.js"
            ],
            "$lib": [
                "../src/lib"
            ],
            "$lib/*": [
                "../src/lib/*"
            ]
        },
        "rootDirs": [
            "..",
            "./types"
        ],
        "verbatimModuleSyntax": true,
        "isolatedModules": true,
        "lib": [
            "esnext",
            "DOM",
            "DOM.Iterable"
        ],
        "moduleResolution": "bundler",
        "module": "esnext",
        "noEmit": true,
        "target": "esnext"
    },
    "include": [
        "ambient.d.ts",
        "non-ambient.d.ts",
        "./types/**/$types.d.ts",
        "../vite.config.js",
        "../vite.config.ts",
        "../src/**/*.js",
        "../src/**/*.ts",
        "../src/**/*.svelte",
        "../tests/**/*.js",
        "../tests/**/*.ts",
        "../tests/**/*.svelte"
    ],
    "exclude": [
        "../node_modules/**",
        "../src/service-worker.js",
        "../src/service-worker/**/*.js",
        "../src/service-worker.ts",
        "../src/service-worker/**/*.ts",
        "../src/service-worker.d.ts",
        "../src/service-worker/**/*.d.ts"
    ]
}
dummdidumm commented 2 months ago

The comment below your include config states:

If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes from the referenced tsconfig.json - TypeScript does not merge them in

You didn't do that, so the only included files are ./src/gtag.d.ts and ../generated/*.ts. These are not .svelte files, and judging from the includes they aren't indirectly included either. So you are very likely in fact not checking any Svelte files.

That said, there could be cases where someone just points to an entry point, and Svelte files are detected from there on. @jasonlyu123 we didn't think about this case, I think need to tweak when the error is thrown (after all the files have been traversed).

rbozan commented 2 months ago

Ah I see... Well I guess it's not really a bug then but it was pretty unexpected because there was nothing in the breaking changes that indicated that I had to change something.