角2 websql键入 [英] angular 2 websql typings

查看:108
本文介绍了角2 websql键入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用angular 4用电子方式编写应用程序.我需要一个数据库,并且想使用websql,但是找不到导入websql类型的方法.

I am writing an app in electron using angular 4. I need a database and want to use websql but I cannot find a way to import websql typings.

我添加了@ types/websql.在我的IDE中,当我这样做时没有编译错误:

I added @types/websql. In my IDE, there is no compil error when i do :

const db: Database = window.openDatabase('foo', '1.0', 'foo', 2 * 1024 * 1024);

但是ng serve给了我:

Property 'openDatabase' does not exist on type 'Window'

我没有任何特定于@types/websql的导入.由于它不是模块,所以我不知道如何导入它.

I do not have any import specific to @types/websql. As it is not a module, I don't know how to import it.

有人对我如何导入它有任何想法吗?

Does anyone have any idea on how I can import this ?

推荐答案

好,我找到了解决方法.

Ok, I found the solution.

ng-cli生成一个tsconfig.app.json,其属性types设置为[]. 如果我正确理解tsc doc,它将阻止编译器使用typeRoots属性.

ng-cli generate a tsconfig.app.json with a property types set to []. If I understand tsc doc correctly, it prevents the compiler to use the typeRoots property.

只需删除此属性,即可编译我的代码.

By simply removing this property, my code compile.

这篇关于角2 websql键入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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