This tool uses jscodeshift to take a set of Sanity CMS schemas in JavaScript format, and convert them to the new TypeScript format supported by Sanity v3.
export default {
name: "person",
title: "Person",
type: "document",
fields: [
{
name: "fullName",
title: "Full name",
type: "string",
},
],
};
import { defineField, defineType } from "sanity";
export const person = defineType({
name: "person",
title: "Person",
type: "document",
fields: [
defineField({
name: "fullName",
title: "Full name",
type: "string",
}),
],
});
npm start -- convert-schemas --input ./src/js-schemas --output ./src/ts-schemas