Skip to content
Tool for generating dom related TypeScript and JavaScript library files
Branch: master
Clone or download
jeffryang24 and sandersn Update Navigator type (#700)
* chore: add system state and capabilities whatwg spec

* feat(idl): add generated widl and commentmap file

* chore(baselines): add generated type

* chore: update baseline

* refactor(baseline): add removed ms-interfaces

* refactor(idlSources): sort idlsource

* refactor(addedTypes): add missing interfaces and MS-specific interfaces

* refactor(overridingTypes): override navigator interface

* refactor(overridingTypes): add missing ms-specific properties in Navigator interface

* chore: update baselines

* refactor(addedTypes): remove redundant interfaces

* chore: update baselines #2

* refactor(addedTypes): remove MSLaunchUriCallback interface

* refactor(knownTypes): add MSLaunchUriCallback inside Window field

* chore: update baselines #3 (with node 12)

* refactor(overridingTypes): restore NavigatorBeacon, activeVRDisplays, and getVRDisplays

* chore: update baselines #4
Latest commit 7f5ab3c Jun 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
baselines Update Navigator type (#700) Jun 20, 2019
inputfiles Update Navigator type (#700) Jun 20, 2019
src Parameterize ProgressEvent (#707) Jun 12, 2019
.gitattributes
.gitignore Update .gitignore May 24, 2018
.mailMap Remove contributor info Jun 20, 2018
.travis.yml Update travis file Mar 1, 2018
AUTHORS.md Update authors Apr 4, 2017
LICENSE.txt add license Nov 11, 2015
README.md Revise the condition to add specs (#708) Jun 7, 2019
build.cmd Revert "Use a separate build script" Mar 1, 2018
build.sh Revert "Use a separate build script" Mar 1, 2018
package-lock.json Update comment maps (#680) Apr 15, 2019
package.json Update comment maps (#680) Apr 15, 2019
tsconfig.json add HTML grouping content types Jun 10, 2018

README.md

TypeScript and JavaScript lib generator

Travis CI Status: Build Status

This tool is used to generate dom.generated.d.ts, webworker.generated.d.ts and dom.iterable.generated.d.ts for TypeScript. The input file is the JSON webidl file generated by the Microsoft Edge browser.

Build Instructions

To get things setup:

npm install

To generate the .d.ts files

npm run build

To test:

npm run test

Contribution Guidelines

The dom.generated.d.ts, webworker.generated.d.ts and dom.iterable.generated.d.ts files from the TypeScript repo are used as baselines. For each pull request, we will run the script and compare the generated files with the baseline files. In order to make the tests pass, please update the baseline as well in any pull requests.

It's recommended to first check which spec the wrong type belongs to. Say we are to update IntersectionObserver which belongs to Intersection Observer spec, and then we can do:

  1. First check we have the spec name Intersection Observer in inputfiles/idlSources.json. If not, add it.
  2. Run npm run fetch-idl "Intersection Observer" && npm run build && npm run baseline-accept.

If the above didn't fix the type issues, we can fix them via json files as a last resort. There are three json files that are typically used to alter the type generation: addedTypes.json, overridingTypes.json, and removedTypes.json. comments.json can used to add comments to the types. Finally, knownTypes.json determine which types are available in a certain environment in case it couldn't be automatically determined.

The format of each file can be inferred from their existing content.

The common steps to send a pull request are:

  1. Open or refer to an issue in the TypeScript repo.
  2. Add missing elements to inputfiles/addedTypes.json, overriding elements to inputfiles/overridingTypes.json, or elements to remove to inputfiles/removedTypes.json.
  3. Run the build script locally to obtain new dom.generated.d.ts and webworker.generated.d.ts.
  4. Update the files in the baselines folder using the newly generated files under generated folder (npm run baseline-accept).

When should a DOM API be included here?

A feature is considered highly experimental if a DOM API lacks multiple implementations or a formal specification from W3C or WHATWG. Such a feature belongs on DefinitelyTyped. When it gets multiple implementations and a proper specification, it can be added here and removed from DefinitelyTyped.

Code Structure

  • src/index.ts: handles the emitting of the .d.ts files.
  • src/test.ts: verifies the output by comparing the generated/ and baseline/ contents.

Input Files

  • browser.webidl.preprocessed.json: a JSON file generated by Microsoft Edge. Do not edit this file.
    • Due to the different update schedules between Edge and TypeScript, this may not be the most up-to-date version of the spec.
  • mdn/apiDescriptions.json: a JSON file generated by fetching API descriptions from MDN. Do not edit this file.
  • addedTypes.json: types that should exist in either browser or webworker but are missing from the Edge spec. The format of the file mimics that of browser.webidl.preprocessed.json.
  • overridingTypes.json: types that are defined in the spec file but has a better or more up-to-date definitions in the json files.
  • removedTypes.json: types that are defined in the spec file but should be removed.
  • comments.json: comment strings to be embedded in the generated .js files.
You can’t perform that action at this time.