Skip to content

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

Closed
@mhegazy

Description

@mhegazy

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.

Activity

NekR

NekR commented on May 4, 2015

@NekR

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

mhegazy commented on May 5, 2015

@mhegazy
ContributorAuthor

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

rielz commented on May 5, 2015

@rielz

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

mhegazy commented on May 5, 2015

@mhegazy
ContributorAuthor

@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

zhengbli commented on May 5, 2015

@zhengbli
Contributor

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

mhegazy commented on Dec 9, 2015

@mhegazy
ContributorAuthor

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.

chicoxyzzy

chicoxyzzy commented on May 1, 2016

@chicoxyzzy
Contributor

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

chicoxyzzy

chicoxyzzy commented on May 1, 2016

@chicoxyzzy
Contributor

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

chicoxyzzy

chicoxyzzy commented on May 1, 2016

@chicoxyzzy
Contributor

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

kitsonk commented on May 2, 2016

@kitsonk
Contributor

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

chicoxyzzy commented on May 2, 2016

@chicoxyzzy
Contributor

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

kitsonk

kitsonk commented on May 2, 2016

@kitsonk
Contributor

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.

1 remaining item

kitsonk

kitsonk commented on May 2, 2016

@kitsonk
Contributor

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

mhegazy commented on May 2, 2016

@mhegazy
ContributorAuthor

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..

added this to the Community milestone on Jan 4, 2018
ShuiRuTian

ShuiRuTian commented on Jun 22, 2020

@ShuiRuTian
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

RyanCavanaugh commented on Jun 22, 2020

@RyanCavanaugh
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zhengbli@NekR@kitsonk@chicoxyzzy@RyanCavanaugh

        Issue actions

          Generate lib.d.ts from w3c dom spec · Issue #3027 · microsoft/TypeScript