Skip to content
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

VS Code only shows types if TypeScript is installed #4267

Closed
robots4life opened this issue Mar 8, 2022 · 6 comments
Closed

VS Code only shows types if TypeScript is installed #4267

robots4life opened this issue Mar 8, 2022 · 6 comments
Labels
bug Something isn't working types / typescript
Milestone

Comments

@robots4life
Copy link

robots4life commented Mar 8, 2022

Describe the bug

Cannot find module '$app/navigation' or its corresponding type declarations. It seems goto cannot be used or something is off with $app/navigation.

Reproduction

https://github.com/robots4life/goto

npm list @sveltejs/kit => goto@0.0.1 /shared/httpd/goto └── @sveltejs/kit@1.0.0-next.294

src/routes/index.svelte

<script>
    import {goto} from '$app/navigation';
	// Cannot find module '$app/navigation' or its corresponding type declarations.js(2307)

    goto('/profile');
</script>

<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>

svelte.config.js

import adapter from '@sveltejs/adapter-auto';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: {
		adapter: adapter(),
	}
};

export default config;

System Info

Linux

System:
    OS: Linux 5.4 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 2.44 GB / 15.53 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 16.14.0 - /opt/nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.17 - /usr/bin/yarn
    npm: 8.3.1 - /opt/nvm/versions/node/v16.14.0/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.31 
    @sveltejs/kit: next => 1.0.0-next.294 
    svelte: ^3.44.0 => 3.46.4

Windows

System:
    OS: Windows 10 10.0.19043
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 8.69 GB / 15.80 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.30)
    Internet Explorer: 11.0.19041.1202
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.31
    @sveltejs/kit: next => 1.0.0-next.294
    svelte: ^3.44.0 => 3.46.4

Severity

blocking all usage of SvelteKit

Additional Information

No response

@robots4life robots4life changed the title Cannot find module '$app/navigation' Cannot find module '$app/navigation' or its corresponding type declarations Mar 8, 2022
@rmunn
Copy link
Contributor

rmunn commented Mar 8, 2022

Going back to Svelte-Kit version 1.0.0-next.288 appears to work, while 1.0.0-next.289 appears to manifest the bug.

@robots4life

This comment was marked as off-topic.

@benmccann
Copy link
Member

I hid your last comment to avoid discussing multiple things here. I have no problem running npx svelte-kit sync on your repo

I confirmed that VS Code is not finding import {goto} from '$app/navigation'; on newly created JS projects. It is however working on TS projects

@benmccann benmccann added this to the 1.0 milestone Mar 8, 2022
@benmccann
Copy link
Member

It works if you install TypeScript. Rich suggested three options: we could a) skip the jsconfig if you choose no typescript, or b) always install typescript regardless of the user's choice. or c) keep things as they are, and tell people that if they want typechecking in their JS project they will need to install typescript

@benmccann benmccann changed the title Cannot find module '$app/navigation' or its corresponding type declarations VS Code only shows types if TypeScript is installed Mar 10, 2022
@benmccann benmccann added the documentation Improvements or additions to documentation label Mar 10, 2022
@jasonlyu123
Copy link
Member

jasonlyu123 commented Mar 11, 2022

I think the root problem is a bug in create-svelte. The only allowed .d.ts file in the js template is global.d.ts. But it has been renamed to app.d.ts. So there isn't an app.d.ts if you chose the js template.

if (file.name.endsWith('global.d.ts')) js.push(file);

@benmccann benmccann added bug Something isn't working and removed documentation Improvements or additions to documentation labels Mar 11, 2022
@benmccann
Copy link
Member

Yes, that was it. Fixed in #4295

A big thank you for finding that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working types / typescript
Projects
None yet
Development

No branches or pull requests

4 participants