Small type usage updates (#1916)

This commit is contained in:
Jaco Greeff
2020-02-21 13:17:40 +01:00
committed by GitHub
parent 19743d6634
commit 8a9e523b84
3 changed files with 5 additions and 10 deletions
-7
View File
@@ -38,13 +38,6 @@ const [nonce, balance] = await api.query.system.account<[Index, AccountData]>(AD
In both these case we can instruct the TypeScript compiler that the type we are expecting in `Index` and `Balance` respectively, not just pure `Codec`. This means that functions like `.toNumber()` is available on both these types - as opposed to just the [general type defaults](types.basics.md#everything-is-a-type) with `.toHex()` and friends.
## Future work
As of this writing, there are still some gray areas to type detection, specifically around the following interfaces -
- `.at` & `.multi` on `api.query` does not (yet) have a `<TypeOverride>` interface. This means `as <TypeOverride>` casts are presently needed for these results
- `api.queryMulti` does not (yet) allow you to provide a hint to the types returned, this ties to the previous point
## Adding user types
In addition to the generated and available interfaces, there is also the ability to [create TypeScript interfaces from your own definitions and well as your on-chain modules](typescript.user.md).