-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Typescript declarations. #283
Conversation
Awesome, thank you very much. We'll review it and merge it shortly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome!
The only think I could see missing was anonymous records (https://deepstream.io/docs/client-js/datasync-anonymous-record/)
I honestly haven't use typescript before so it may be good for someone else to pitch in and try it out, but it got my thumbs otherwise. If that proves to be hard to find I will make some time early next week to try it out
|
||
interface RecordStatic { | ||
/** Get a record. */ | ||
getRecord(path: string): Record; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAnonymousRecord is missing here ( as well as an interface )
Any chance anyone tested or used this? Be great to get in for 2.1 |
What's the schedule for 2.1? We noticed a couple of issues that need to be addressed with the typings. |
We are aiming to get it out by early next week. No rush though, we can easily just merge it in when your happy and do a separate release, our release cycle is mostly automated ;) =D |
I started trying out this declaration file and immediately ran into a few issues. First of all, none of the interfaces or enums are exported, so it's impossible to store values like the |
I believe you can use strings in Enums now in Typescript like this: |
I'm sorry for the delay on merging this, we are still trying to figure out the best way of testing and maintaining it going forward. It will be merged, just pending the next client milestone. |
} | ||
interface deepstreamStatic { | ||
CONSTANTS: { | ||
[key: string]: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works. We'll also want to update the enums to use strings. Typescript enums compile to integers.
@jensvdh @benjaminVadon Are you both okay with me merging this? |
I'm OK with merging this. It's not perfect yet but we can improve on it in a 2nd PR. Have these typings is still an improvement over having none. |
Agreed! |
One last thing, would you be okay with signing the CLA? https://deepstream.io/info/community/cla/ I have said that a bit often lately so if you already have my bad! |
Done! |
Awesome, and thanks again for raising this! |
Hi,
I added Typescript definitions to this repository. This should help Typescript developers a lot by providing type declarations for this repository.
See issue #256
Big thanks to @RichiWIP whom provided the first version of a Typescript declaration file.
I decided to follow Microsoft's recommended new guidelines that suggest bundling the Typescript Declarations with the module and adding a reference to package.json. Therefore developers won't have to download the typescript definitions from an external repository.
see:
https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html
Alternatively we can create a second repository and submit our typings to Microsoft's @types project directly. However, this process is more involved and no longer seems recommended.
I added some steps to readme.md to get Typescript developers started. Let me know if you'd like to put this documentation somewhere else.