json2ts
json2ts copied to clipboard
Convert method is crashed with an empty array
Hey! Please, review this issue. Convert method of Json2Ts instance is crashed with an empty array as argument.
import { Json2Ts } from 'json2ts/src/json2ts';
const json = [];
const tsString = new Json2Ts().convert(JSON.stringify(json));
As the result application is failed with an error:
TypeError: Cannot read properties of undefined (reading 'replace')
at Json2Ts.formatCharsToTypeScript
In my opinion it should return interface like this - export interface RootObject {}
. Can we review this issue as a bug and fix inside the library or it should be handled outside?