在打字稿中使用chrome扩展apis [英] Using chrome extension apis in typescript

查看:236
本文介绍了在打字稿中使用chrome扩展apis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个用TypeScript编写的chrome扩展。我正在使用WebStorm,并且在我的项目中添加了 chrome-DefiniteltyTyped 库。然而,当我写这在我的脚本代码: chrome.extension.getURL
我得到一个错误:找不到名字'chrome'


你们有什么解决方案吗?

这应该很好: 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆