T.Djahel T.Djahel - 7 days ago 6
TypeScript Question

Using chrome extension apis in typescript

I'm building a chrome extension written in TypeScript. I'm using WebStorm and I added the

chrome-DefiniteltyTyped
library in my project.

However, when I write this in my typescript code :
chrome.extension.getURL

I got an error :
cannot find name 'chrome'
.

Because of this, my javascript file is not generated and I cannot use it in my extension.

Do you guys have any solution?

Answer

That should work fine : https://github.com/borisyankov/DefinitelyTyped/blob/master/chrome/chrome.d.ts#L851-L870

TIP: make sure you have a reference tag added:

/// <reference path="pathTo/chrome.d.ts"/>

Comments