json-to-ts
json-to-ts copied to clipboard
String literals?
In the example:
const JsonToTS = require('json-to-ts')
const json = {
cats: [
{name: 'Kittin'},
{name: 'Mittin'}
],
favoriteNumber: 42,
favoriteWord: 'Hello'
}
JsonToTS(json).forEach( typeInterface => {
console.log(typeInterface)
})
I am in a situation where I would expect
interface Cat {
name: CatLiteralString;
}
rather than string
However I can understand situations where one would want string
rather than a literal...
So my thinking is maybe we could have an option allowing us to define keys that should be string literals?
for example
JsonToTS(json,{ literals: ['name'] })
which could maybe naively treat all string name
properties as literals ?
Thoughts?