TypeScript migration guide
This guide covers the gradual migration of the SuperDoc monorepo from JavaScript to TypeScript.Quick start
Infrastructure is ready. You can now:- Create new files as
.tsor.vuewith<script lang="ts"> - Migrate existing
.jsfiles when making significant changes - Mix
.jsand.tsfiles freely - they work together
npm run types:check --workspace=packages/super-editor
When to migrate a file
Convert to TypeScript when:- Making significant changes - Refactoring or adding major features
- Creating new files - All new files should be
.ts(or.vuewith TypeScript) - Working on core logic - Prioritize type safety in critical paths
- Fixing type-related bugs - Convert to prevent similar issues
How to migrate
1. Basic function
Before (helper.js):
helper.ts):
2. Vue components
Before:<script setup> (recommended):
3. Prefer unknown over any
Type checking
Package-specific (recommended)
Root level
Common issues
Type errors in JavaScript files
EnsurecheckJs: false in your tsconfig. Only .ts files are type-checked during migration.
Build fails after migrating a file
Run a clean build:Migration priority
Suggested order:- Utilities and helpers - Pure functions, easy to type
- Core types - Type definitions and interfaces
- Extensions - Self-contained modules
- Commands - Clear input/output
- Components - Vue components (can stay JS longer)
Testing
- Tests can stay as
.jsfiles initially - They’ll import TypeScript modules normally
- Run tests as usual:
npm test
Advanced patterns
ProseMirror types
Extension pattern
Discriminated unions
Resources
Questions?
- Check this guide first
- Look at
packages/aifor a fully migrated example - Ask in team chat
- Update this guide with new learnings
Last Updated: Phase 0 Complete (Infrastructure Setup)

