Using chrome extension apis in typescript
As of typescript 2 (or 2.x, not sure), you should import the chrome types from @types.
in package.json:
"devDependencies": {
...
"@types/chrome": "0.0.35", // or just npm install --save-dev @types/chrome
And in tsconfig:
"types": [
//(various types, e.g. jquery, core-js),
"chrome"
]
That should work fine : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/chrome/index.d.ts
TIP: make sure you have a reference
tag added:
/// <reference path="pathTo/chrome.d.ts"/>
You just need to install Type definition to make it work, let's install it:
yarn add @types/chrome --dev
or NPM
npm install @types/chrome --save-dev
now use free of error!