Json to TS
Forked from
https://github.com/MariusAlch/json-to-ts
which version is 1.7.0
.
Convert json object to typescript interfaces
Example
Code
import JsonToTS from "https://deno.land/x/json_to_ts@v1.7.0/mod.ts";
const json = {
cats: [
{ name: "Kittin" },
{ name: "Mittin" },
],
favoriteNumber: 42,
favoriteWord: "Hello",
};
JsonToTS(json).forEach((typeInterface) => {
console.log(typeInterface);
});
Output:
interface RootObject {
cats: Cat[];
favoriteNumber: number;
favoriteWord: string;
}
interface Cat {
name: string;
}
Converter
- Array type merging (Big deal)
- Union types
- Duplicate type prevention
- Optional types
- Array types