-
-
Notifications
You must be signed in to change notification settings - Fork 5
Migration (v3 to v4)
Λlisue (Ali sue・ありすえ) edited this page Aug 2, 2024
·
4 revisions
- Use alternative functions of deprecated functions
-
is.RecordLike
tois.Record
-
is.RecordLikeOf(...)
tois.RecordOf(...)
-
is.ReadonlyTupleOf(...)
tois.ReadonlyOf(is.TupleOf(...))
-
is.ReadonlyUniformTupleOf(...)
tois.ReadonlyOf(is.UniformTupleOf(...))
-
is.ObjectOf(..., { strict: true })
tois.StrictOf(is.ObjectOf(...))
-
is.OneOf(...)
tois.UnionOf(...)
-
is.AllOf(...)
tois.IntersectionOf(...)
-
- Rename
is.BigInt(...)
tois.Bigint(...)
- Rename
is.OptionalOf(...)
toas.Optional(...)
- Remove obsolete functions/types
isReadonly
isUnwrapReadonlyOf
getMetadata
getPredicateFactoryMetadata
setPredicateFactoryMetadata
GetMetadata
WithMetadata
PredicateFactoryMetadata
- Update
jsr:@core/unknownutil@^3.0.0
tojsr:@core/unknownutil@^4.0.0
- Execute the following migration script for simple replacements
import { walk } from "jsr:@std/fs/walk";
const version = "^4.0.0";
function migrate(text: string): string {
text = text.replace(
/import(\s+){(.*)}(\s+)from(\s+)"jsr:?@core\/unknownutil@3.*"/g,
`import$1{$2}$3from$4"jsr:@core/unknownutil@${version}"`,
);
text = text.replace(/is\.RecordLike/g, "is.Record");
text = text.replace(/is\.RecordLikeOf\((.*?)\)/g, "is.RecordOf($1)");
text = text.replace(
/is\.ReadonlyTupleOf\((.*?)\)/g,
"is.ReadonlyOf(is.Tuple($1))",
);
text = text.replace(
/is\.ReadonlyUniformTupleOf\((.*?)\)/g,
"is.ReadonlyOf(is.UniformTuple($1))",
);
text = text.replace(/is\.OneOf\((.*?)\)/g, "is.UnionOf($1)");
text = text.replace(/is\.AllOf\((.*?)\)/g, "is.IntersectionOf($1)");
text = text.replace(/is\.BigInt/g, "is.Bigint");
text = text.replace(/is\.OptionalOf/g, "as.Optional");
if (text.includes("as.Optional")) {
text = text.replace(
/import(\s+){(.*)\bis\b(.*)}(\s+)from/g,
"import$1{$2as, is$3}$4from",
);
}
return text;
}
for await (const entry of walk(".")) {
if (entry.path === import.meta.filename) continue;
if (entry.isFile && entry.name.endsWith(".ts")) {
let text = await Deno.readTextFile(entry.path);
text = migrate(text);
await Deno.writeTextFile(entry.path, text);
}
}