gbdrt commented on issue #72: Adding type definitions for typescript
URL: 
https://github.com/apache/incubator-openwhisk-client-js/pull/72#issuecomment-329480529
 
 
   There are some tools to generate the type definitions from an API 
description which can give a rough first version, and help to maintain the 
project.
   
   Unfortunately the Openwhisk API description is not up-to-date with the 
implementation. 
   I generated the type definitions manually using both the API description and 
a lot of tests.
   Then I added the definitions for the shortcuts that are documented here: 
https://github.com/apache/incubator-openwhisk-client-js/blob/master/README.md
   
   I also overloaded some methods with advanced type annotations that are 
useful for the developer. For instance if I use:
   ```
   const res = ow.actions.invoke<In, Out>{
     name: 'xxxx',
     blocking: true,
     result: true,
     params: p
   }
   ```
   
   The compiler forces the parameter `p` to be of type `In` and knows that the 
output is of type `Promise<Out>`.
   
   In the same vein there are multiple overloadings of the `invoke` function 
because the output type depends on the value of the parameters `blocking` and 
`result`. 
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to