Git Product home page Git Product logo

Comments (7)

nharlow89 avatar nharlow89 commented on June 2, 2024 8

Additionally, the EthereumProvider type only contains a single field (isMetaMask). It would be very useful to have full provider typing here!

from detect-provider.

joelamouche avatar joelamouche commented on June 2, 2024 6

+1

It would be better if it returned EthereumProvider | null

from detect-provider.

mcmire avatar mcmire commented on June 2, 2024 1

This is fixed in #41, but we have yet to release a new version.

from detect-provider.

spb-web avatar spb-web commented on June 2, 2024

+1

from detect-provider.

pyoner avatar pyoner commented on June 2, 2024

got dist/index.d.ts with Promise<unknown>

interface EthereumProvider {
    isMetaMask?: boolean;
}
declare global {
    interface Window {
        ethereum?: EthereumProvider;
    }
}
export = detectEthereumProvider;
/**
 * Returns a Promise that resolves to the value of window.ethereum if it is
 * set within the given timeout, or null.
 * The Promise will not reject, but an error will be thrown if invalid options
 * are provided.
 *
 * @param options - Options bag.
 * @param options.mustBeMetaMask - Whether to only look for MetaMask providers.
 * Default: false
 * @param options.silent - Whether to silence console errors. Does not affect
 * thrown errors. Default: false
 * @param options.timeout - Milliseconds to wait for 'ethereum#initialized' to
 * be dispatched. Default: 3000
 * @returns A Promise that resolves with the Provider if it is detected within
 * given timeout, otherwise null.
 */
declare function detectEthereumProvider({ mustBeMetaMask, silent, timeout, }?: {
    mustBeMetaMask?: boolean | undefined;
    silent?: boolean | undefined;
    timeout?: number | undefined;
}): Promise<unknown>;

from detect-provider.

martonlederer avatar martonlederer commented on June 2, 2024

Still no new version, it is a bit annoying to deal with these types myself

from detect-provider.

mcmire avatar mcmire commented on June 2, 2024

2.0.0 is released with proper types to remind you to handle null in your code. Please let us know if you're still having problems and we'll look into it further!

from detect-provider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.