mrjono1 / joi-to-typescript

Convert Joi Schemas to TypeScript interfaces
MIT License
124 stars 38 forks source link

Allow `baseType` meta to be used in general, not only for unsupported types #428

Closed cmaster11 closed 5 months ago

cmaster11 commented 5 months ago

This PR allows users to say e.g.

    const schema = Joi.object({
      one: Joi.any(),
      two: Joi.any().meta({ baseType: 'number | string' })
    }).meta({ className: 'Test' });

and get

export interface Test {
  one?: any;
  two?: number | string;
}

Previously this was not possible because e.g. Any is a supported schema that only maps to any.

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c94f1ef) 98.45% compared to head (9eb921f) 98.46%. Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #428 +/- ## ======================================= Coverage 98.45% 98.46% ======================================= Files 9 9 Lines 648 650 +2 Branches 260 251 -9 ======================================= + Hits 638 640 +2 Misses 10 10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.