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

Make global declaration the default #8276

Closed
CaptainCodeman opened this issue Dec 29, 2022 · 2 comments · Fixed by #8477
Closed

Make global declaration the default #8276

CaptainCodeman opened this issue Dec 29, 2022 · 2 comments · Fixed by #8477

Comments

@CaptainCodeman
Copy link
Contributor

CaptainCodeman commented Dec 29, 2022

Describe the problem

Seems like every day someone will have an issue with trying to import types in src/app.d.ts

Describe the proposed solution

Why not make the declare global { version the default?

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

@dummdidumm
Copy link
Member

IIRC declare global only works if there is an import in the file

@CaptainCodeman
Copy link
Contributor Author

Ah, I was wondering what I must be missing

Adding something to force it to be a module might be confusing, although it may still help, e.g.:

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare global {
  namespace App {
    interface Locals {
      name: string
    }
    // interface PageData {}
    // interface Error {}
    // interface Platform {}
  }
}

// this line can be removed if you add an import to this file:
export default undefined;

Rich-Harris added a commit that referenced this issue Jan 13, 2023
* fix: adjust `app.d.ts` to diminish confusion about imports

closes #8276

* Apply suggestions from code review

* Update packages/kit/types/ambient.d.ts

Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants