kit icon indicating copy to clipboard operation
kit copied to clipboard

Make global declaration the default

Open CaptainCodeman opened this issue 3 years ago • 2 comments

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

CaptainCodeman avatar Dec 29 '22 01:12 CaptainCodeman

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

dummdidumm avatar Dec 29 '22 07:12 dummdidumm

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;

CaptainCodeman avatar Dec 29 '22 16:12 CaptainCodeman