-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat: ts definitions #4
Conversation
Thanks for submitting this. Doing it as a Could you please update the PR to do that? |
Done, although currently, the generation fails thanks to Gozala/web-encoding#7 So I guess the NPM publish would fail thanks to that as well, so will have to resolve that issue first. |
Fix in the |
Adds a `generate-types` command to generate `*.d.ts` files. Largely inspired by @AuHau's work on achingbrain/uint8arrays#4
One thing you may want to consider is to generate types into separate dir e.g. |
I would be a bit against to put it into I am open to change this and will leave that up to @achingbrain but since this package follows a bit different structure than the standard "put everything into Hmm did not know about |
My interpretation of unspoken rule was build artifacts go to
I think types usually host typedefs for third party package defs that were not found in
I don't hold strong preferences either way, just want to consolidate on the similar pattern across different packages in the ecosystem. For IPFS I went with placing them in Edit: Only reason I generally don't like generating
I think it is fairly new, or at least I have discovered it pretty recently myself. As of |
😅 Well, you are right I guess. Just coming from TS development background we use the following structure for general libraries and so I was a bit biased here:
But it is true that I can't think of some really "true" setup that is standardized for TS development. For example I saw some people replacing But if you would put it into
That is possible, but we use bit different setup 😅
Interesting, you are right! It works :-D I just tried it on this PR... It feels still a bit weird to "abuse" this field in this way. I still think that for general usage the TLDR; @achingbrain let me know what you think, I am fine with whatever 😆 |
It is a good question in this repo context, in cases where there's an |
Since Happy to re-evaluate if it causes problems/affront. |
Wait, it does? I did not know that! Well if that is the case, then for sure I would go that way! I have updated the PR then :-) |
Small clarification, |
@achingbrain what about this PR? 😇 |
ipfs/aegir#671 has just landed in aegir which adds typedef generation support so hopefully this should become obsolete and we can handle it all through the tooling. |
Minimal updates to add autogenerated typescript types via aegir. Used this doc to help: https://github.com/ipfs/aegir/blob/master/md/ts-jsdoc.md I tested this PR locally, linking this to a test project (including updated `web-encoding` dependency) to make sure the types all line up. See #4 (comment) Resolves #3
Superseded by #7 |
Since you have good JSDoc types it was easy-peasy to generate these. You can regenerate that easily with running
tsc -d --emitDeclarationOnly --allowJs *.js
.tsc
is already bundled inaegir
.Maybe it is worth considering to have this command in
prePublish
hook and generate those upon release? And not polluting the repo?Closes #3