Skip to content

microsoft/TypeScript-DOM-lib-generator

Repository files navigation

TypeScript and JavaScript lib generator

This tool is used to generate dom.generated.d.ts and webworker.generated.d.ts for TypeScript, and domWeb.js and domWindows.js for Visual Studio JavaScript language service. The input file is the XML spec file generated by the Microsoft Edge browser.

Build Instruction

Required Software: Visual Studio 2015 Community Version (with Visual F# installed)

To build the tool, simply open the Generator.sln in Visual Studio and build the solution. A nuget restore should be done automatically before the build.

Press F5 in Visual Studio to run the tool. If it runs successfully, the output files will be generated under the generated folder.

Code Structure

  • Shared.fs: handles the parsing from XML spec file, and stores the common data structures for later use;
  • TS.fs: handles the emitting of the lib.d.ts file;
  • JS.fs: handles the emitting of the domWeb.js and domWindows.js files used for Visual Studio JavaScript language service;
  • Program.fs: entry point of the tool;

Input Files:

  • browser.webidl.xml: the XML spec file generated by Microsoft Edge (due to the different updating schedules between Edge and TypeScript, this may not be the most up-to-date version of the spec.);
  • webworker.webidl.xml: contains additional types for webworker.
  • addedTypes.json: types that should exist in either browser or webworker but are missing from the Edge spec. The type can be property, method, interface, constructor, or indexer.
  • 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
  • jsTemplate.js: the initial templates for domWeb.js and domWindows.js, which contains the necessary helper functions;
  • sample.json: sample json file used to tell F# json type provider that structure of the json files. The content of it is not used anywhere.

About

Tool for generating dom related TypeScript and JavaScript library files

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 239