-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
444d60f
commit 8af96ce
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SvelteKit Sync | ||
|
||
`svelte-kit sync` creates the tsconfig.json and all generated types for your project. This is useful because Sveltekit has [generated types](https://kit.svelte.dev/docs/types#generated-types). | ||
|
||
Example: | ||
|
||
```tsx | ||
import { API_KEY } from '$env/static/private'; | ||
// ^? Module '"$env/static/private"' has no exported member 'API_KEY'. | ||
``` | ||
|
||
Running `svelte-kit sync` will generate the correct types and remove the error: | ||
|
||
```tsx | ||
import { API_KEY } from '$env/static/private'; | ||
// ^? (alias) const API_KEY: string | ||
``` | ||
|
||
You'll find the generated types under the `.svelte-kit` folder. Here is the one for environment variables: | ||
|
||
```tsx | ||
// .svelte-kit/ambient.d.ts | ||
declare module '$env/static/private' { | ||
export const API_KEY: string; | ||
... | ||
} | ||
``` |