prismatic-io / spectral

Prismatic's typescript library for custom components
https://prismatic.io/docs/spectral/custom-component-library
35 stars 2 forks source link

CNI - Fix Model union types that are objects, arrays, escaped characters #252

Closed jasoncomes closed 2 months ago

jasoncomes commented 2 months ago

The components that utilize models can employ an arbitrary data type, which can be arrays, objects, or even escaped characters. To properly type this, we need to validate what these data types are and then return the correct corresponding types.

# duro-plm

SyntaxError: ';' expected. (15:17)
  13 |  * @example [{\"con\": \"asc\"}]
  14 |  */
> 15 |   orderBy?: "[{"con": "asc"}]" | "[{"con": "desc"}]" | "[{"lastModified": "asc"}]" | "[{"lastModified": "desc"}]" | "[{"name": "asc"}]" | "[{"name": "desc"}]";
     |                 ^
  16 |    /**
  17 |  * First N Items
  18 |  * The number of items to return.
# text-manipulation

SyntaxError: Unterminated string literal. (18:18)
  16 |  * @placeholder The type of newline to use
  17 |  */
> 18 |   newlineType?: "
     |                  ^
  19 | " | "
  20 | ";
  21 |    /**