Skip to content

Add basic TypeScript declaration files (first pass)#50

Open
singingwolfboy wants to merge 1 commit intoinukshuk:mainfrom
singingwolfboy:ts-type-declarations
Open

Add basic TypeScript declaration files (first pass)#50
singingwolfboy wants to merge 1 commit intoinukshuk:mainfrom
singingwolfboy:ts-type-declarations

Conversation

@singingwolfboy
Copy link

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:

  1. Forked the repo to singingwolfboy/edtf.ts
  2. Renamed all the *.js files to *.ts, and added the TypeScript dependency to package.json
  3. 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
  4. Committed my type annotations to my fork (where they are still visible)
  5. Ran npx tsc --declaration --emitDeclarationOnly to make TypeScript generate the declaration files for me
  6. 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, and date.js. There are plenty of any types 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant