Misleading types for `EnsProvider.getResolver()`
See original GitHub issueThe getResolver()
method on the EnsProvider
interface is declared with the following signature
export interface EnsProvider {
getResolver(name: string): Promise<EnsResolver | null>;
}
The implementation of getResolver()
can return null
though https://github.com/ethers-io/ethers.js/blob/4e9394554b1f05400ea4e0529d33e1d4efe78247/packages/providers/src.ts/base-provider.ts#L1515-L1524
This leads to callers of getResolver()
not anticipating null
as the return value which leads to runtime errors even though type-checking passes. I’d expect the following signature.
export interface EnsProvider {
getResolver(name: string): Promise<EnsResolver | null>;
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
ethersproject/providers - UNPKG
1, "use strict";. 2. 3, import {. 4, Block, BlockTag, BlockWithTransactions, EventType, Filter, FilterByBlockHash, ForkEvent,. 5, Listener, Log, Provider, ...
Read more >EIP-5131: SAFE Authentication For ENS
Abstract. This EIP links one or more signing wallets via Ethereum Name Service Specification (EIP-137) to prove control and asset ownership ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m adding this locally for the next minor bump now. 😃
Keep in mind a large portion of the library will still have the same problem if you are. “anticipating” things to not be null. The library is overall designed around the
strict
error in the TypeScript checker turned off, so anything can return null.This is changed in v6 (which uses
strict
errors), and has required a lot of little changes, and v6 is still not ready for a public beta yet. But for the most part in v5, these sorts of changes will not be made anymore…The types have been updated in 5.5.0.
Thanks! 😃