mrjono1 / joi-to-typescript

Convert Joi Schemas to TypeScript interfaces
MIT License
125 stars 40 forks source link

Little refactoring + fix of content prefix when wrapping union (`|`) members #421

Closed cmaster11 closed 9 months ago

cmaster11 commented 9 months ago

This PR fixes a bug where alternatives members would not be properly wrapped with parenthesis resulting in invalid typings:

export interface HelloTest {
  /**
   * A multiline
   * description
   */
  template?:
    /**
     * Some alternatives
     */
    | ( <---- This ( was missing
    /**
     * Alternative 1
     */
    | string
    /**
     * Alternative 2
     */
    | string[]) ( <---- This ) was missing
    /**
     * A boolean
     */
    | true;
}
codecov[bot] commented 9 months ago

Codecov Report

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

Comparison is base (cddfd75) 98.74% compared to head (c4f189c) 98.45%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #421 +/- ## ========================================== - Coverage 98.74% 98.45% -0.30% ========================================== Files 9 9 Lines 639 648 +9 Branches 255 260 +5 ========================================== + Hits 631 638 +7 - Misses 8 10 +2 ```

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