Typescript d.ts
lommez opened this issue · 12 comments
Hi Nathanael,
Do you have plans for creating the type definitions for the library?
Hi @lommez - any reason you want the definitions? Just curious 😄 if it's for intellisense your IDE should have localStorage available from the browser spec and since the API is the exact same (last I checked) it should work. If there's another reason you want the typings, let me know and I can throw something together to improve this piece. I love good type definitions 👍 just want to make sure we are on the same page for needing it here. I'm using VSCode and when coding on a .ts file it picks up the Storage
object and provides the intellisense when keying localStorage
or sessionStorage
Hi Brad,
Sorry for the delay.
That´s my case, the AoT and tree shaking features.
Gonna take a run at this soon @lommez
This will likely require a few test runs from you @lommez to make sure it works 😄 hope you are able to help out. I have a def file ready and it works but I'm not 100% certain it's perfect for this case. Since this module contains both sessionStorage
and localStorage
it might need to be expanded a bit. I'll submit the d.ts in a PR in a few and you can try it in your project and see if it is sufficient for AoT or not.
PR#11 has the d.ts
file @lommez if you want to try it out and see if it's sufficient to get AoT working
@lommez - I'm thinking right now that if this doesn't work we need to add the methods to a global
augmentation definition and namespace both localStorage
and sessionStorage
and have all the methods duped for both. That might be the trick for AoT here and the better approach actually going forward 👍 so keep me posted on your progress here please.
hi @bradmartin !
Thanks so much and I'm sorry for the long delay to answer you.
I will take look at this file and give you a feedback as soon as possible.
@bradmartin,
I tried to use your file but didn't work. Don't you have to extend an interface or something like that?
I'm not entirely sure what is really needed for the aot bits. Written many definitions for plugins and I know some work with aot, or so I'm told :) so I thought that would be it. With this plugin exposing the names session and localStorage it might take a little more work to get it working.
Any news on this?
@IngoBleile -- Brad created some typings #11 - but no one has confirmed they work -- so I haven't accepted the PR. I'm pretty sure they work as Brad is the man! But I personally would hate to accept a PR that I don't know for sure works. And since this is open source work, this is extremely low on my todo list to actually spin up another test app in TS to test the typings vs pretty much any other work ...
So if you want to contribute; grab the typings test them out and then let me know if they work. 😀