Skip to content

feat: add type definition #68

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

Merged
merged 4 commits into from
Oct 5, 2024
Merged

feat: add type definition #68

merged 4 commits into from
Oct 5, 2024

Conversation

adenvt
Copy link
Contributor

@adenvt adenvt commented Sep 20, 2024

Add type definition for typescript user

@romainmenke
Copy link
Member

Hi @adenvt,

Thank you for your contribution 🎉

Personally I don't find it is maintainable to have a manual .d.ts file.
I think that this places the highest burden on maintainers and provides the least value/assurances.

So I don't think we can accept this even if I appreciate your effort.


However I would consider a change that adds JSDoc type annotations.

Benefits of JSDOc annotations:

  • can be tested
  • helps maintainers to write better code
  • .d.ts files can be generated from them

Stylelint for example uses such a setup : https://github.com/stylelint/stylelint

@adenvt
Copy link
Contributor Author

adenvt commented Sep 30, 2024

@romainmenke Thank for reviewing.

I'm update it, and follow your approach to use JSDoc and generate .d.ts from it. I did:

  • Add script npm run build-types to generate .d.ts
  • Update lib/index.js to has more strict type.
  • Update script/clean.js to remove types/* before build
  • Update .gitignore

Copy link
Member

@romainmenke romainmenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adenvt Thank you for your contribution!


I've made a few more edits:

  • ensure that types are present in git, as this makes them visible on GitHub
  • add types to sources.js
  • add type checks with tsc
  • fix some internal issues surfaced by the type checks.

@romainmenke romainmenke enabled auto-merge (squash) October 5, 2024 13:06
@romainmenke romainmenke disabled auto-merge October 5, 2024 13:43
@romainmenke romainmenke merged commit 48ad525 into mrhenry:main Oct 5, 2024
6 of 17 checks passed
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.

3 participants