在打字稿中使用chrome扩展apis [英] Using chrome extension apis in typescript
问题描述
我正在构建一个用TypeScript编写的chrome扩展。我正在使用WebStorm,并且在我的项目中添加了 chrome-DefiniteltyTyped
库。然而,当我写这在我的脚本代码: chrome.extension.getURL
我得到一个错误:找不到名字'chrome'$ c $因为这个原因,我的javascript文件没有生成,我不能在我的扩展中使用它。
你们有什么解决方案吗?
这应该很好: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/chrome/index.d .ts
提示:确保您添加了参考
标签:
///< reference path =pathTo / chrome.d.ts/>
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?
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"/>
这篇关于在打字稿中使用chrome扩展apis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!