Last active
July 6, 2025 07:09
-
-
Save joshnuss/87b910cbf9d33208b85da4bebca7247f to your computer and use it in GitHub Desktop.
Revisions
-
joshnuss revised this gist
Jun 16, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -63,7 +63,7 @@ import adapter from '@sveltejs/adapter-auto' /** @type {import('@sveltejs/kit').Config} */ const config = { + preprocess: vitePreprocess(), kit: { // ... } -
joshnuss revised this gist
Jun 16, 2024 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -54,3 +54,18 @@ export {}; - Rename `src/routes/*.js` -> `src/routes/*.ts`, and add types. - Add `<script lang="ts">` to `src/routes/*.svelte`, and related types. - Rename `vite.config.js` -> `vite.config.ts` - Add `vitePreprocessor` to `svelte.config.js` ```diff import adapter from '@sveltejs/adapter-auto' + import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' /** @type {import('@sveltejs/kit').Config} */ const config = { + preprocess: vitePreprocess(), + kit: { // ... } } ``` -
joshnuss revised this gist
Jun 15, 2024 . 1 changed file with 0 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -22,11 +22,6 @@ pnpm i -D typescript tslib svelte-check "strict": true, "moduleResolution": "bundler" } } ``` -
joshnuss revised this gist
Jun 15, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ pnpm i -D typescript tslib svelte-check - Add a `tsconfig.json` ```javascript { "extends": "./.svelte-kit/tsconfig.json", "compilerOptions": { -
joshnuss created this gist
Jun 15, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ # Converting a JavaScript SvelteKit app to TypeScript - Install `typescript`, `tslib`, and `svelte-check` for dev mode ```bash pnpm i -D typescript tslib svelte-check ``` - Add a `tsconfig.json` ```json { "extends": "./.svelte-kit/tsconfig.json", "compilerOptions": { "allowJs": true, "checkJs": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": true, "strict": true, "moduleResolution": "bundler" } // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files // // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes // from the referenced tsconfig.json - TypeScript does not merge them in } ``` - Add `scripts` to `package.json`: ```json "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" ``` - Add an `src/app.d.ts` ```typescript // See https://kit.svelte.dev/docs/types#app // for information about these interfaces declare global { namespace App { // interface Error {} // interface Locals {} // interface PageData {} // interface PageState {} // interface Platform {} } } export {}; ``` - Rename `src/lib/*.js` -> `src/lib/*.ts`, and add types. - Rename `src/routes/*.js` -> `src/routes/*.ts`, and add types. - Add `<script lang="ts">` to `src/routes/*.svelte`, and related types. - Rename `vite.config.js` -> `vite.config.ts`