/mon2ts

Primary LanguageJavaScript

Mongoose models to Typescript interfaces generator

N|Solid

Script generates typescript interfaces with all properties from mongoose models.

Install:

npm install mon2ts --save

Example usage:

//get generator script
let m2t = require('mon2ts');
//get mongoose model
let model = require('./models/MyModel');
//generate typescript interface as string
let str = m2t(model);
//save the string as .ts somewhere you need it

Additional info:

Script automatically generates import statements for referred models & additional interfaces for nested objects. Accepted type for referred mongoose model is either id or populated interface.