-
Notifications
You must be signed in to change notification settings - Fork 72
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
Consider adding TypeScript types to packages #937
Comments
Thanks for the offer ;) Isn't that what microsoft/TypeScript-DOM-lib-generator, based on Webref data and distributed in the I personally tend to like the idea that, apart from a tiny bit of JavaScript code in the packages that consumers can happily ignore, Webref data does not force the use of any particular programming language. I'm sure I can be persuaded otherwise though ;) |
@types/web covers most interfaces but doesn't cover CSS data. csstype has historically used MDN data to generate strict CSS types but it would be nice to migrate to webref. Currently @types/web writes its own types for webref. Other TypeScript-based generators would need to do the same, so this puts some extra work on those using the package. (but since it can be autogenerated, it's admittedly not that much work.) I don't feel that shipping an |
OK, that seems good indeed. @dontcallmedom and I are not TypeScript experts. If we can take you up on your offer to craft a pull request, that would help us assess whether we can easily maintain this afterwards :) Also tagging @saschanaz for perspective and possible overlap with, or usefulness for, |
@types/web implementation also depends on BCD data to make sure things are implemented by two distinct browser engines and also adds several typescript-specific manual modifications e.g. generics. Perhaps webref could provide a way to decide whether to add a type or not. But I'm not sure it's worth to reimplement all of that here instead of extending @types/web to better support CSS, if that's the main reason. The lack of better CSS support was mainly because CSS syntax is complex enough to limit things based on implementation status, but I guess that's now at least better with foolip/mdn-bcd-collector#1805. (And also because there's no full time worker focusing on that library, I'm just maintaining it in my free time. Which means, PRs welcome.) Also, webref would need to coordinate with Microsoft or it'll cause a lot of conflict with the existing libraries depending on the current @types/web definitions. (Microsoft wants to put such coordination inside their own repo because of their internal policy, which is why the library is in Microsoft org right now. Maybe we can start some talk to change that...) |
csstype provides an equivalent to I'm not advocating for generating DOM types here, but instead types for the |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Oh wait, you mean you just want this? https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/main/src/build/webref/webref-idl.d.ts I was totally misunderstanding then, I'm all for that. And I don't think it'll be any hard to maintain. |
Yes, I just wanted something like that file with a little more detail based on the existing JSON schema. I started working on the PR but will hold off on publishing for now, because there's some bugs with reffy's JSON schema I noticed. Will try to resolve those first. |
TypeScript is used by a significant number of projects and adding TypeScript types would make it easier to know the shape of the returned objects.
Since the JSON files are all validated against a JSON Schema, types can be automatically generated using a tool like json-schema-to-typescript. You'd only need a small amount of manual work to add a type definition for the
listAll
function.Happy to open a PR for this :)
The text was updated successfully, but these errors were encountered: