Skip to content

Commit

Permalink
build: simplify typescript update script (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomulik authored May 19, 2021
1 parent c7d5a6d commit 5e41135
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/update-endpoints/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@ function sortEndpoints(endpoints) {
}

function endpointToTypes(endpoint) {
const key = endpointToKey(endpoint);
const response = endpoint.resultsKey
? `Endpoints["GET ${endpoint.url}"]["response"] & { data: Endpoints["GET ${endpoint.url}"]["response"]["data"]["${endpoint.resultsKey}"] }`
: `Endpoints["GET ${endpoint.url}"]["response"]`;
? `Endpoints[${key}]["response"] & { data: Endpoints[${key}]["response"]["data"]["${endpoint.resultsKey}"] }`
: `Endpoints[${key}]["response"]`;

return `
/**
* @see ${endpoint.documentationUrl}
*/
"GET ${endpoint.url}": {
parameters: Endpoints["GET ${endpoint.url}"]["parameters"];
${key}: {
parameters: Endpoints[${key}]["parameters"];
response: ${response};
};
`;
Expand Down

0 comments on commit 5e41135

Please sign in to comment.