Skip to content
Discussion options

You must be logged in to vote

When you put an import inside a declaration file it turns into an es6 module (except when the import is under a module declaration), Thus the declaration of App stops being global and you are left with the default one.

To fix the issue simply wrap the namespace declaration with declare global like this:

/// <reference types="@sveltejs/kit" />

// See https://kit.svelte.dev/docs#typescript
// for information about these interfaces

import type { User } from './routes/foo';

declare global {
	declare namespace App {
		interface Locals {
			user: User;
		}

		interface Platform {}

		interface Session {}

		interface Stuff {}
	}
}

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@MISTOM
Comment options

Answer selected by dummdidumm
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
6 participants
Converted from issue

This discussion was converted from issue #3766 on February 08, 2022 08:43.