For Typescript Users
mitter.io SDKs are compiled with typescript 3.0.3, but target typescript 2.7.+ Versions of typescript below 2.7 might work, but are not supported.
All mitter.io web/javacsript SDKs are written in typescript and as such are bundled with typings automatically. This section details on how to optimally use the mitter.io libraries if you are using typescript.
Type-matching functions
If you are using type-matching functions to get the type of a payload for example, the functions are implemented as predicates, so typescript will automatically cast it within the branch. For example:
Instead, if you were to use the bundled type-matching functions:
API calls using clients
All bundled clients are typed and will throw an error when using incorrect request/response values
NOTE The above does not apply if you are using fetch and/or axios to make API calls. The internal clients that are used with restyped are exposed in case you wish to use them with your own axios clients. Do refer to the ts-docs bundled with
@mitter-io/core
on how to access these objects.
Last updated