Skip to content

Commit

Permalink
Add generic type for resolve-value
Browse files Browse the repository at this point in the history
If used in a codebase where an ethereum-provider is expected that doesn’t have an on() method and instead has a different API.
  • Loading branch information
rubenswieringa committed Mar 15, 2022
1 parent 2969f2c commit 11135b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export = detectEthereumProvider;
* @returns A Promise that resolves with the Provider if it is detected within
* given timeout, otherwise null.
*/
function detectEthereumProvider({
function detectEthereumProvider<T = MetaMaskEthereumProvider>({
mustBeMetaMask = false,
silent = false,
timeout = 3000,
} = {}): Promise<MetaMaskEthereumProvider | null> {
} = {}): Promise<T | null> {

_validateInputs();

Expand Down Expand Up @@ -70,7 +70,7 @@ function detectEthereumProvider({
const { ethereum } = window as Window;

if (ethereum && (!mustBeMetaMask || ethereum.isMetaMask)) {
resolve(ethereum);
resolve(ethereum as unknown as T);
} else {

const message = mustBeMetaMask && ethereum
Expand Down

0 comments on commit 11135b9

Please sign in to comment.