· 1 min read
Migrating from JS + JSDoc to TypeScript
Renamed jsconfig.json → tsconfig.json and pointed the check scripts at it.
What we did
- Renamed
jsconfig.json→tsconfig.jsonand pointed thecheckscripts at it. - Renamed
vite.config.js,src/routes/+layout.jsandsrc/lib/index.jsto.ts. Updated the#libentry in theimportsmap inpackage.json. - Switched
+layout.svelteto<script lang="ts">and typed$props()withSnippet. - Documented the
Appinterfaces inapp.d.ts.
What I learned
- 0 errors doesn't mean typed. After removing the JSDoc,
childrenwas silentlyanyand svelte-check still passed. import typeis erased at build time. It only exists for the type checker.app.d.tsholds global types.export {}makes the file a module, sodeclare globalis needed to makeApp.*visible everywhere.- On a static site,
LocalsandPlatformare effectively unused because there's no server at runtime.PageData,PageStateandErrorcan still matter client-side. - Git shows renames as delete + add until the files are staged.
git mvrecords them directly.
Problems & fixes
pnpm lintfailed becausepackage.jsonlost its final newline after the edit. Fixed withpnpm format.
Next
- Phase 2: layout, routing and base path (
resolve()from$app/paths).