-
Notifications
You must be signed in to change notification settings - Fork 9
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
Make API Typescript friendly #19
Comments
i'm all for community contribution! so sure throw out a pull request, that would be fantastic. |
Pull request submitted. |
Thanks, changes look good - I'll see about running some tests with this as well. Appreciate the Contribution! |
More to come 😃 |
I merged your latest typescript changes into master testing seems good |
Excellent. That leaves adding better type declarations (right now everything is 'any')
Any preference? I can do either, but am more familiar with 2) |
i'm cool with 2 - i'm comfortable enough with Typescript to just have it converted completely |
Done 2) and submitted a pull request. Making it work with both is a right pain though and very fragile. |
It would not take much to make the API Typescript friendly.
The steps would be:
Running the typescript compiler would generate files with typed function signatures for each Javascript file.
These signatures help modern code editors (e.g. vscode) with code completion even when using Javascript, not Typescript.
The Typescript compiler will also generate a copy of the Javascript files with some added code to make the library usable with both old-style 'require' and modern 'import' statements. This is a big advantage in my opinion.
The signature files and slightly changed Javascript files would be generated in a separate directory (e.g. 'dist').
The deployment of the library as an npm would change slightly (generated from 'dist/src' folder, not 'src' folder).
This approach would need no changes to the codebase (except, optionally, addition of some comments).
The generated files (apart from the type definitions) would still be (almost unchanged) Javascript.
I have implemented this approach in a fork and could supply a pull request.
I'd prefer this to be a part of this repository rather than having to maintain a separate one (and keep it up-to-date).
Is this desired? Should we discuss?
The text was updated successfully, but these errors were encountered: