Migrating a TS file
Goal: Apply the TS→SJS rewrite checklist on a real module.
- Rename
.ts→.sjs. - Fix banned constructs (
any→dynamic,enum→sum types). - Run
superjs migrate from-prototypeif imports still point at prototype paths. - Run
superjs checkuntil clean.
Full guide: Migration.
Example
// After migration — no any, no enum
type Role = Admin | Member
type User {
name: string;
role: Role;
}
function roleLabel(u: User): string {
return match u.role {
Admin => "admin",
Member => "member",
}
}Key takeaways
- Migrate leaf modules first.
- Use the compat matrix for npm wrappers.
superjs migrate from-tsassists bulk moves.