After reading around about Typescript and continuously getting the impression that there’s more documentation about it than ES6, I’m trying to move my project to Typescript - now that it’s in the very initial stages.
I’m having issues with localforage however.
In ES6 I initialized it with var localForage = require('localforage');
and it worked fine.
In Typescript, I’m getting an error on the require keyword (it cannot be found).
I’ve tried different things and always end up getting require not found or localforage not found.
I managed to get it work after some attempts with TSD and typings - I still get error messages at the CLI but the codes runs…
@xr0master how should I add the definition and what would be the TS syntax?
I use localforage to store some data as from what I understood it’s the best and most flexible option to store & load simple data. Would you suggest something else?
Personally I think this is a mistake. I realize it’s the default, but I don’t understand the purpose of crippling TypeScript like this. IMHO, both noImplicitAny and noEmitOnError should always be set.
If you’re still trying to figure out localForage, I did a writeup on how to use it for Ionic 2. It is one of many good ways to store data in an Ionic 2 app.
Hopefully it helps you or someone else looking for the same topic
Thanks for this great write up Nic. We’re evaluating adding localforage into Ionic 2 out of the box, especially as we look toward supporting indexeddb for PWAs. This helped us