chrome-types icon indicating copy to clipboard operation
chrome-types copied to clipboard

Property 'OnInstalledReason' does not exist on type 'typeof runtime'.ts(2339)

Open ezolcem opened this issue 1 year ago • 3 comments

https://developer.chrome.com/docs/extensions/reference/api/runtime#example-uninstall-url

chrome.runtime.onInstalled.addListener(details => {
  if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
    chrome.runtime.setUninstallURL('https://example.com/extension-survey');
  }
});

TypeScript gives error:

Property 'OnInstalledReason' does not exist on type 'typeof runtime'.ts(2339)

ezolcem avatar Jun 30 '24 07:06 ezolcem

The @types/chrome type library seems to be more comprehensive.

ouweiya avatar Sep 04 '24 20:09 ouweiya

The @types/chrome type library seems to be more comprehensive.

I agree, there are few types missing from chrome-types in addition to the above - chrome.runtime.lastError also isn't available as well, however @types/chrome works well.

ad1992 avatar Sep 11 '24 11:09 ad1992

The current issue I have with @types/chrome is the lack of Promise overflows. It always types extension v3 calls as synchronous with callback even if I prepend an await or add a .then().catch(). In the end I decided to use chrome-types and just provide my own global types for the enums I want to reference.

jpc-ae avatar Jan 10 '25 23:01 jpc-ae