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

LayoutData not correctly inferred #1809

Open
simonh1000 opened this issue Dec 24, 2022 · 1 comment
Open

LayoutData not correctly inferred #1809

simonh1000 opened this issue Dec 24, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@simonh1000
Copy link

simonh1000 commented Dec 24, 2022

Describe the bug

+layout.ts

export const load = (async ({ url }) => {
    try {
        let user: null | { user: string, player: string } = await Promise.resolve(null);
        return user;
    } catch (err) {
        throw redirect(301, "/login");
    }
}) satisfies LayoutLoad

in +layout.svelte

<script lang="ts">
	import type { LayoutData } from './$types';

	// Data from +page.ts
	export let data: LayoutData;
    let user;
    if (data) {
        user = data.user;
    }
</script>

LayoutData is inferred as {} which then leaves lots of other errors in the my code

Reproduction

See description

Expected behaviour

LayoutData should be null | { user: string, player: string }

System Info

MacOS, VSCode

Which package is the issue about?

svelte-language-server

Additional Information, eg. Screenshots

No response

@simonh1000 simonh1000 added the bug Something isn't working label Dec 24, 2022
@ohmree
Copy link

ohmree commented Jan 28, 2023

I ran into a similar issue on arch linux using emacs and lsp-mode, turns out I still had the package nodejs-svelte-language-server-git installed (it must've been removed from the aur sometime after I installed it) and updating to a more recent version (0.15.3) using the nodejs-svelte-language-server package fixed it.

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

2 participants