angularjsgruntjstypescriptsession-storageng-storage

how to run ngStorage with typeScript


is it possible to include ngStorage within typeScript? I get TS2304 error but I can't find .d.ts file at definitelyTyped I could include. I wanna store tokens which I use in REST requests. Any other suggestions on this? I couldn't make it working with $sessionStorage either. Apparently I don't have enough knowledge about typeScript, I might not include something I should have. Thanks in advance.


Solution

  • Short Answer

    Yes!

    Longer answer

    Yes you can use ngStorage with TypeScript.

    Being that TypeScript is a superset of JavaScript, so anything you can do in JavaScript you can do in TypeScript (Note there are some differences, but not in regards to using other libraries). If you are unable to find a .d.ts file for this module then you have two choices to use it.

    1. Specify the type of any of the services/factories to have a type of any
    2. Create your own .d.ts to represent this module, or at least the pieces of it that you are using

    If you decide to head down the route of #2, it would be nice for the community to submit a pull request to the definitely typed repo to include the definition you created.