Skip to content

Commit

Permalink
lib(api): improve CSSIStation ResultsData intellisense by using Pick<>
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaggyTech committed Dec 25, 2024
1 parent df7c10f commit 2940636
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/lib/src/api/cssiStation/cssiStation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,20 +732,18 @@ export type CSSIResultsData = {
}

/**
* Types the `Results[]` of the `CSSIStation API` via `Pick` for better end user experience.
* Types the `Results[]` of the `CSSI Station API` via `Pick` for better end user experience.
*/
export type CSSIPickResults<T extends 'default'> =
/* Pick<> ProductsResultsData based on Variant string */
T extends 'default'
? /* Path /vehicle/models - all properties defined */
{
[K in keyof CSSIResultsData]-?: CSSIResultsData[K]
}
: /* fallback default value - all optional properties */
CSSIResultsData
export type CSSIPickResults<T extends 'default'> = T extends 'default'
? /* endpoint always has all properties defined */
{
[K in keyof CSSIResultsData]-?: CSSIResultsData[K]
}
: /* fallback default value - all properties */
CSSIResultsData

/**
* Types the return of the `products()` function.
* Types the return of the `cssiStation()` function.
*
* The `Results[]` will be typed as `CSSIResultsData`
*/
Expand Down

0 comments on commit 2940636

Please sign in to comment.