From 0523ab9ae0f21860a04e88bcc077761501220f6d Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Tue, 17 Jan 2023 23:50:06 +0100 Subject: [PATCH] docs: explain how to add ambient typings (#8558) * docs: explain how to add ambient typings closes #8527 * Update packages/kit/types/ambient.d.ts Co-authored-by: Rich Harris --- .changeset/curvy-chefs-design.md | 5 +++++ packages/kit/types/ambient.d.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/curvy-chefs-design.md diff --git a/.changeset/curvy-chefs-design.md b/.changeset/curvy-chefs-design.md new file mode 100644 index 000000000000..4a4d97743d03 --- /dev/null +++ b/.changeset/curvy-chefs-design.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +docs: explain how to add ambient typings diff --git a/packages/kit/types/ambient.d.ts b/packages/kit/types/ambient.d.ts index f781c274dcaa..d4ed8951b6b4 100644 --- a/packages/kit/types/ambient.d.ts +++ b/packages/kit/types/ambient.d.ts @@ -11,9 +11,12 @@ * } * } * - * export default undefined; + * export {}; * ``` * + * The `export {}` line exists because without it, the file would be treated as an _ambient module_ which prevents you from adding `import` declarations. + * If you need to add ambient `declare module` declarations, do so in a separate file like `src/ambient.d.ts`. + * * By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions. */ declare namespace App {