Skip to content

extends... in jsconfig causes warnings in editors #4428

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
stephane-vanraes opened this issue Mar 23, 2022 · 6 comments
Closed

extends... in jsconfig causes warnings in editors #4428

stephane-vanraes opened this issue Mar 23, 2022 · 6 comments

Comments

@stephane-vanraes
Copy link
Contributor

stephane-vanraes commented Mar 23, 2022

Describe the bug

VSCode gives type warnings in vanilla js

Removing the following from jsconfig.json fixes this:

"extends": "./.svelte-kit/tsconfig.json"

This shouldn't happen if you are not using typescript.

Reproduction

Create a brand new SvelteKit project, skeleton, no typescript.
Add following to index.svelte

<script>
    import { session } from '$app/stores'
</script>

{$session.lang}

VSCode will now mark lang with a warning/error saying Property 'lang' lang does not exist on type 'Session'

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
    Memory: 13.28 GB / 31.71 GB
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.46)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.33
    @sveltejs/kit: next => 1.0.0-next.302
    svelte: ^3.44.0 => 3.46.4

Severity

annoyance

Additional Information

No response

@dummdidumm
Copy link
Member

dummdidumm commented Mar 23, 2022

From the reproducible it sounds like the warning is expected. The config which the jsconfig extends from turns on type checks für JavaScript(Svelte) files. If you don't want that, you can change it to

{
  "extends": "./.svelte-kit/tsconfig.json",
  "compilerOptions": {
    "checkJs": false
  }
}

As an alternative, if you want type checking, adjust the app.d.ts file and add lang to the Session interface in there.

@stephane-vanraes
Copy link
Contributor Author

I might have explained it wrong, the warning is not expected since I do not expect to have type checks turned on if not using TypesScript. Maybe this is just a matter of setting checkJS to false if the user chooses to not use TS in the template ?

@gtm-nayan
Copy link
Contributor

Related #4427. Both seem to have stemmed from checkJs being true now in the generated tsconfig since it was never brought up earlier.

@dummdidumm
Copy link
Member

You both are right. The previous behavior was to only introduce a jsconfig without setting something like checkJs. We should most likely revert this part (although it's arguably helpful to have type checking by default for JS projects, too).

@Rich-Harris
Copy link
Member

Cross-posting from #4495:


I almost wonder if we need to have two separate prompts when setting up a project, where if you don't opt in to TypeScript-the-language you can still opt in to typechecking:

? Use TypeScript? › Yes
? Use TypeScript? › No
? Add typechecking for JavaScript? › No / Yes

Personally I would choose No and Yes, but I don't know if I'm in a sufficiently small minority that that would be annoying for most non-TypeScript users.

@Rich-Harris
Copy link
Member

We can close this now, as jsconfig.json is only generated if you choose 'Type-checked JavaScript' when scaffolding the project, and the extended config doesn't include checkJs (it's part of the default jsconfig.json if you opt in)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants