Codemod
Dry run first:
npx uql-codemod --dry-runneeds a decision: src/entity/audit.ts:9: cannot infer 'type' for Json<Payload>23 file(s) would change1 property(ies) left untouched; see aboveneeds a decision: is something it will not guess at, and the run exits 1 while any remain.
worth a look: is a rewrite it did make that you may still want to read.
Then drop the flag to write the changes. Edits are spliced into the text rather than the file being
reprinted, so everything it does not touch stays byte for byte as you wrote it, comments and
formatting included. Point it elsewhere with --project=<path>, or narrow it to certain paths with
--include=<a,b>. It reads a real tsconfig.json rather than parsing one, because half the job is
writing down types and only the checker knows what role?: Role resolves to.
What it rewrites
Section titled “What it rewrites”typeon a@Field/@Idthat has none, from the property’s declared type.entity: () => Xon a relation, unwrapping arrays and the oldRelation<T>alias.Relation<T>toT, its import going with the last use.virtualtocomputed.raw('SQL')to the tagged template, an alias argument moving onto.as().- The
idKeybrand on a key not calledid,_idoruuid, and on every composite. - Deletes
import 'reflect-metadata', andexperimentalDecorators/emitDecoratorMetadatafrom yourtsconfig.json.
What it leaves to you
Section titled “What it leaves to you”Anything where the choice is yours, reported rather than guessed. It exits 1 when something is
left, 0 when nothing is, and 2 when it could not start at all.
@Transactional(),@InjectQuerier(),@Log()and@Serialized(), which no longer exist. A@Transactional()method becomes apool.transaction()around its body, and only you know which pool.- Options it cannot read:
@Field(shared), a spread, or a@Fieldnever called. - A property whose type maps to no column, and a key written under a computed name.
- A branded string id, written as
type: Stringto keep the column you have.'uuid'is a native column, and a migration. target: esnext, the one target that leaves decorators untransformed. Any other modern one works.
Then run tsc
Section titled “Then run tsc”That is the rest of the migration, and the point of it. Everything the codemod inserts is checked against the property it describes, so anything it got wrong is a compile error rather than a quietly wrong column. What each release asks beyond this is in the upgrade guide.