edtf.js
edtf.js copied to clipboard
Add basic TypeScript declaration files (first pass)
First attempt at fixing #49.
I'm pretty decent at writing TypeScript, but I have less experience with writing TS declaration files, and I don't know the logic of this codebase well enough to add correct annotations everywhere. Therefore, in order to make this pull request, I did the following:
- Forked the repo to
singingwolfboy/edtf.ts - Renamed all the
*.jsfiles to*.ts, and added the TypeScript dependency topackage.json - Spent some time looking through the codebase, annotating types where I could -- including making educated guesses when I didn't entirely understand what the code was doing
- Committed my type annotations to my fork (where they are still visible)
- Ran
npx tsc --declaration --emitDeclarationOnlyto make TypeScript generate the declaration files for me - Made a new branch off of the latest code in
inukshuk/edtf.js, added a commit with those declaration files, and made this pull request
Some important caveats:
- I have not done any testing that these declaration files get picked up correctly by developers using TypeScript. This pull request should be considered a quick "first pass" implementation, not a tested & polished final implementation.
- I have not added type annotations to every file. I mostly focused on
parser.js,interface.js, anddate.js. There are plenty ofanytypes in these declaration files, which can (and probably should!) be narrowed to something more specific.
If you are not interested in merging this pull request as a result of the above caveats, I completely understand. My goal is to demonstrate how we might start to add types to this codebase, in the hopes of inspiring others to complete a more robust implementation. I intend to keep my fork up on GitHub, so that others can view the TypeScript annotations in the code, and maybe fork my work and continue it to completion.