thegreenwebfoundation / co2.js

An npm module for accessing the green web API, and estimating the carbon emissions from using digital services
Other
375 stars 47 forks source link

Add type-check and type-emit steps for type annotation code to the current js code #199

Open mrchrisadams opened 4 months ago

mrchrisadams commented 4 months ago

Earlier this week, @sfishel18 proposed the following as a way to improve support for typescript style annotations, while keeping the code accessible to people who aren't familiar with typescript:

what i would propose is:

  1. as much as possible, leave the source code exactly as-is. the files continue to be .js and jsdoc comments are used to declare types. introducing .d.ts files is a last resort for very complex types.
  2. add a "type check" step to the CI process that checks to make sure the code itself matches the types that are declared
  3. add a "type emit" step to the npm publish process that generates a full set of .d.ts files from the declared types and includes that in the published artifacts

Source: Introduce just enough typescript · Issue #77 · thegreenwebfoundation/co2.js by @github

This sounds good, and this issue is exists as a place to link future PRs that implement the various steps outlined above.

I'm going to be on annual leave for a few weeks, and there are a few other demands on @fershad's time as a maintainer.

@sfishel18 - if you're able to lead on this one, we'd be grateful.

sfishel18 commented 4 months ago

@mrchrisadams sounds great, i'm on it! enjoy your leave!

i'll try to get some proof-of-concept level code into a branch soon, and create a draft PR linked to this issue so others can see what i'm up to

sfishel18 commented 3 months ago

my PR is ready for an initial look when one of you has a chance. though @fershad it occurs to me that if there are already a lot of demands on you as a maintainer, a large PR to review probably doesn't help with that :) any other ways i can contribute here (issue triage, writing tests, writing docs, etc)? i'm up for anything