Skip to content

Misleading types for EnsProvider.getResolver() #1850

@geigerzaehler

Description

@geigerzaehler

The 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

async getResolver(name: string): Promise<Resolver> {
try {
const address = await this._getResolver(name);
if (address == null) { return null; }
return new Resolver(this, address, name);
} catch (error) {
if (error.code === Logger.errors.CALL_EXCEPTION) { return null; }
return null;
}
}

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>;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    minor-bumpPlanned for the next minor version bump.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions