Answer the question
In order to leave comments, you need to log in
How to do proper type checking?
There is such a code
const installed = window.getOfflineSigner && window.keplr
const enable = () => {
if (installed) return window.keplr.enable(chainId)
}
Answer the question
In order to leave comments, you need to log in
https://www.typescriptlang.org/docs/handbook/2/nar...
type Keplr = {
enable(chainId: ChainId): Enable;
};
const isInstalled = (v: unknown): v is Keplr => !!(window.getOfflineSigner && v)
const enable = () => {
if (isInstalled(window.keplr)) return window.keplr.enable(chainId)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question