Skip to content

Generate lib.d.ts from w3c dom spec #3027

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

Closed
mhegazy opened this issue May 4, 2015 · 17 comments
Closed

Generate lib.d.ts from w3c dom spec #3027

mhegazy opened this issue May 4, 2015 · 17 comments
Labels
Help Wanted You can do this Suggestion An idea for TypeScript
Milestone

Comments

@mhegazy
Copy link
Contributor

mhegazy commented May 4, 2015

lib.d.ts should be created from http://www.w3.org/TR/dom/.

We already have a script that generates the lib from a webidl file.

@NekR
Copy link

NekR commented May 4, 2015

We already have a script that generates the lib from a webidl file.

Is problem here what that webidl file tightly coupled to IE or problem is what scripts extracts data only from IE?

Just want to understand if this issue requires script to be build or just dedicated webidl definition. If last, then probably easier way is to just grab it from blink/webkit/gecko sources and modify to not be vendor specific.

@mhegazy
Copy link
Contributor Author

mhegazy commented May 5, 2015

Is problem here what that webidl file tightly coupled to IE or problem is what scripts extracts data only from IE?

the problem is that the webidl is from IE :D

Just want to understand if this issue requires script to be build or just dedicated webidl definition. If last, then probably easier way is to just grab it from blink/webkit/gecko sources and modify to not be vendor specific.

I am not sure starting from different vendor-specific idl definition solves the problem, assuming that we are looking for the standard.

What i need to research, is there is a .webidl file with the standard that we can run our script against, we need a new tool that can look at another format to generate the lib.

@rielz
Copy link

rielz commented May 5, 2015

Extracting WebIDL from the spec is actually not a problem. The IDL parts are found in <pre> tags with idl class.
That is true for most of the specs at w3.org and whatwg.org, but some of them might contain non-standard IDL.

Example for DOM4: https://gist.github.com/rielz/af4d8e75b147c5f4bc69
Also WebGL: https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl

@mhegazy
Copy link
Contributor Author

mhegazy commented May 5, 2015

@zhengbli can you share your script to create a .d.ts. We can put it in a different repro so we can iterate on it, and allow others to help as well.

@zhengbli
Copy link
Contributor

zhengbli commented May 5, 2015

Sure I'll do that soon. However the script is for parsing the XML spec files instead of the idl files we got from the IE team.

@mhegazy
Copy link
Contributor Author

mhegazy commented Dec 9, 2015

lib.d.ts generation script is now open source under https://github.com/Microsoft/TSJS-lib-generator. PR's to generate a more standards-friendly version are welcomed.

@mhegazy mhegazy added the Help Wanted You can do this label Dec 9, 2015
@chicoxyzzy
Copy link
Contributor

Does it generates definitions for whatwg spec? Looks like it generates definitions based on some Edge's IDL

@chicoxyzzy
Copy link
Contributor

chicoxyzzy commented May 1, 2016

also are these definition in lib.dom.d.ts now?

@chicoxyzzy
Copy link
Contributor

chicoxyzzy commented May 1, 2016

and how to contribute to this file or should I contribute to Edge IDL or somewhere else?
because this should be valid https://www.typescriptlang.org/play/#src=new%20Text(%22test%22)%3B according to spec

@kitsonk
Copy link
Contributor

kitsonk commented May 2, 2016

The contribution guidelines are available in the project's README. Essentially you contribute by overriding whatever is auto-generated as laid out in the steps provided. Also opening an issue with the repository, if you don't feel comfortable submitting the PR, might get someone else to go ahead and make the change.

@chicoxyzzy
Copy link
Contributor

It's still not clear how exactly definitions are generated. Can you explain this process a little bit?

@kitsonk
Copy link
Contributor

kitsonk commented May 2, 2016

When the TypeScript team regularly generate the library files as part of the build process. The team use whatever the master version of TSJS-lib-generator that is available, so merged PRs there will effect the output of that tool, ergo, effect what is included with the next release of TypeScript.

@chicoxyzzy
Copy link
Contributor

What IDL is used as source? It seems like it is some Edge IDL not WHATWG IDL

@kitsonk
Copy link
Contributor

kitsonk commented May 2, 2016

That is what this whole ticket is about. Currently the tool uses the Edge IDL, though @mhegazy suggested some other way would be better, but this issue being still open and the labels indicate that the TypeScript community is open to considering to moving to a different way, but in the priority of the backlog, they are leaving it open to the larger community to make the change if they do so.

It is likely any change to the WHATWG IDL will cause some significant regressions in functionality of already existing code and therefore isn't a straight forward swap, visualised here:

the_api_catalog_is_a_tool_to_visualize_and_analyze_the_api_overlap_between_standards_specifications_and_support_across_browsers_

Source: data.microsoftedge.com API Catalog

@mhegazy
Copy link
Contributor Author

mhegazy commented May 2, 2016

As i have noted earlier, the script that generates the library is available under r https://github.com/Microsoft/TSJS-lib-generator, and we would be happy to look at a PR that makes the generation more standards compliant.

We will have to look at the differences of the resulting library file and the one we have now (created from Edge IDL + hand authored augmentations). and based on this decide how to surface that to the user, i.e. 1. as a single standard lib, 2. as flavored lib with --lib flag, e.g. dom.chrome, dom.edge, etc..

@ShuiRuTian
Copy link
Contributor

emmmm, is this issue fixed? It does fetch "https://dom.spec.whatwg.org/" form idlSource.json to generate d.ts now.
If not, what does it still need to do?

@RyanCavanaugh
Copy link
Member

Yeah, this has basically been implemented at https://github.com/microsoft/TSJS-lib-generator . We use a slightly different IDL file but the differences are basically immaterial at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

8 participants