Open
Description
When targetting typescript interfaces, an empty object in the samples generates an empty interface. An empty interface, as per the linter has a big drawback:
An empty interface declaration allows any non-nullish value, including literals like
0
and""
.
- If that's what you want, disable this lint rule with an inline comment or configure the 'allowInterfaces' rule option.
- If you want a type meaning "any object", you probably want
object
instead.- If you want a type meaning "any value", you probably want
unknown
So it probably needs to be object
in such cases. More information
Issue Type
output
Context (Environment, Version, Language)
Input Format: json
Output Language: typescript
CLI, npm, or app.quicktype.io: app.quicktype.io
Version: n/a
Description
It trips the linter. But more importantly, see linter message - an empty interface doesn't restrict a value to an empty object, which is what you might expect, but that's not how it works.
Input Data
{
"Labels": {
"AccountNumber": "Accountnumber",
"Title": "Create new Service Address"
},
"Hints": {
}
}
Expected Behaviour / Output
export interface Welcome {
readonly Labels: Labels;
readonly Hints: object;
}
export interface Labels {
readonly AccountNumber: string;
readonly Title: string;
}
Current Behaviour / Output
export interface Welcome {
readonly Labels: Labels;
readonly Hints: Hints;
}
export interface Hints {
}
export interface Labels {
readonly AccountNumber: string;
readonly Title: string;
}
Steps to Reproduce
- Paste the input in https://app.quicktype.io/#l=ts
- Observe output