-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #531 from hey-api/chore/clients-openapi-ts-changes
chore: update openapi-ts for clients work
- Loading branch information
Showing
11 changed files
with
501 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import ts from 'typescript'; | ||
|
||
import { isType } from './utils'; | ||
|
||
/** | ||
* Create a return function call statement. | ||
* Example `return fn<string>(params)`. | ||
* @param args arguments to pass to the function. | ||
* @param name name of the function to call. | ||
* @param types list of function types | ||
* @returns ts.ReturnStatement | ||
*/ | ||
export const createReturnFunctionCall = ({ | ||
args = [], | ||
name, | ||
types = [], | ||
}: { | ||
args: any[]; | ||
name: string; | ||
types?: string[]; | ||
}) => { | ||
const expression = ts.factory.createCallExpression( | ||
ts.factory.createIdentifier(name), | ||
types.map((type) => ts.factory.createTypeReferenceNode(type)), | ||
args | ||
.map((arg) => | ||
ts.isExpression(arg) ? arg : ts.factory.createIdentifier(arg), | ||
) | ||
.filter(isType<ts.Identifier | ts.Expression>), | ||
); | ||
const statement = ts.factory.createReturnStatement(expression); | ||
return statement; | ||
}; |
Oops, something went wrong.