Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular 2 websql typings

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.

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);

but ng serve gives me :

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

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 ?

like image 751
ctruchi Avatar asked Nov 01 '25 23:11

ctruchi


1 Answers

Ok, I found the solution.

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.

like image 126
ctruchi Avatar answered Nov 04 '25 17:11

ctruchi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!