joi-to-typescript
joi-to-typescript copied to clipboard
Redundant typing
I found an issue, which I think is related to #53
Starting Schema - schema/Base.ts
export const InteractionTypeSchema = Joi.string().valid("CREATE", "DELETE", "UPDATE")
.meta({ className: 'InteractionType' });
export const InteractionSchema = Joi.object({
companyId: Joi.string().required(),
userId: Joi.string().required(),
appVersion: Joi.string().required(),
interactionType: InteractionTypeSchema,
})
.meta({ className: 'Interaction' });
Generates - interfaces/Base.ts
export interface Interaction {
appVersion: string;
companyId: string;
interactionType?: InteractionType | 'CREATE' | 'DELETE' | 'UPDATE';
userId: string;
}
export type InteractionType = 'CREATE' | 'DELETE' | 'UPDATE';
I think interactionType should only reference InteractionType and not CREATE, DELETE, UPDATE
I was just about to file an identical issue with basically exactly the same example code. Even though this has no impact in practice, it makes interfaces really ugly and confusing. Bug is present in 4.0.5.
Duplicate of issue #149