Skip to content

Commit

Permalink
Create sveltekit-sync.md
Browse files Browse the repository at this point in the history
  • Loading branch information
petermekhaeil authored Dec 7, 2023
1 parent 444d60f commit 8af96ce
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions learnings/sveltekit-sync.md
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;
...
}
```

0 comments on commit 8af96ce

Please sign in to comment.