Giter VIP home page Giter VIP logo

typescript-dom-lib-generator's Introduction

TypeScript and JavaScript lib generator

This tool is used to generate the web-based lib.dom.d.ts file which is included with TypeScript releases, and as the @types/web package.

Why is my fancy API still not available here?

A feature needs to be supported by two or more major browser engines to be included here, to make sure there is a good consensus among vendors: Gecko (Firefox), Blink (Chrome/Edge), and WebKit (Safari).

If the condition is met but still is not available here, first check the contribution guidelines below and then please file an issue.

Build Instructions

To get things setup:

npm install

To generate the .d.ts files

npm run build

To test:

npm run test

@types/[lib] to TypeScript Versions

@types/[lib] version TypeScript Version Minimum TypeScript Support
@types/web 0.0.1 ~4.3 4.4
@types/web 0.0.2 ~4.4 beta 4.4
@types/web 0.0.25 4.4 4.4
@types/web 0.0.28 4.5 beta 4.4
@types/web 0.0.37 4.5 rc 4.4
@types/web 0.0.37 4.5 4.4
@types/web 0.0.50 4.6 beta 4.4
@types/web 0.0.51 4.6 rc 4.4
@types/web 0.0.51 4.6 4.4
@types/web 0.0.61 4.7 beta 4.4
@types/web 0.0.61 4.7 rc 4.4
@types/web 0.0.61 4.7 4.4
@types/web 0.0.68 4.8 beta 4.4
@types/web 0.0.69 4.8 rc 4.4
@types/web 0.0.69 4.8 4.4
@types/web 0.0.76 4.9 4.4

@types/[lib] Minimum Target

The libraries available on @types/ like @types/web require a "target" of ES6 or above, because iterator APIs are included.

Contribution Guidelines

The files in the baselines/ directory 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.

When the type is missing

It's possible that the automated algorithm decided that it's not well supported by browsers and thus removed it. Say we want to add a new interface named Foo. Check if there is a document about that interface in MDN. If there is, see the browser compatibility section and check whether it's supported by two or more browser engines. (Note that Chromium-based browsers use the same browser engine and thus support from them counts as a single support.)

If all the conditions are fulfilled, it could be that the type is incorrectly removed by inputfiles/removedTypes.jsonc. Try finding and removing the relevant item there and run npm run build && npm run baseline-accept.

If conditions are not fulfilled but you think MDN is wrong, please file an issue at https://github.com/mdn/browser-compat-data/issues/. The type will be automatically added in a few weeks when MDN fixes their data.

When the type exists but is wrong

It's possible that the type is too specific or too general. First you need to check whether inputfiles/overridingTypes.jsonc or inputfiles/addedTypes.jsonc have a relevant item, which can be fixed if exists. If they don't, add one in overridingTypes.jsonc. Run npm run build && npm run baseline-accept to make sure the resulting changes are what you want.

If you are familiar with Web IDL, you may also want to check whether the upstream IDL itself can be made more specific. Doing so will reduce the need for manual overrides in this repository and thus can be more helpful.

This repo

Code Structure

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

Input Files

  • mdn/apiDescriptions.json: a JSON file generated by fetching API descriptions from MDN. Do not edit this file.
  • addedTypes.jsonc: types that should exist but are missing from the spec data.
  • overridingTypes.jsonc: types that are defined in the spec but have TypeScript-friendly modifications in the json files.
  • removedTypes.jsonc: types that are defined in the spec but should be removed.
  • comments.json: comment strings to be embedded in the generated .js files.
  • deprecatedMessage.json: the reason why one type is deprecated. The reason why it is a separate file rather than merge in comment.json is mdn/apiDescriptions.json would also possibly be deprecated.

Deployment to TypeScript

To migrate the *.d.ts files into TypeScript:

  1. Trigger the workflow here - this will send a PR to TypeScript under your alias.

  2. Update the README table with the mappings for versions in the @types/[lib]. E.g. TS 4.5 -> @types/web 0.0.23. Find that number here: https://www.npmjs.com/package/@types/web

  3. Generate a CHANGELOG for the releases:

    #                       lib        from  to
    npm run ts-changelog -- @types/web 0.0.2 0.0.23

    You might need to run git pull origin main --tags to run this ^

  4. Add the CHANGELOG to the release issue

typescript-dom-lib-generator's People

Contributors

saschanaz avatar mhegazy avatar zhengbli avatar sandersn avatar orta avatar mattiasbuelens avatar dependabot[bot] avatar yuichinukiyama avatar falsandtru avatar typescript-bot avatar a-tarasyuk avatar 43081j avatar danielrosenwasser avatar irrationalrock avatar github-actions[bot] avatar franklinwhale avatar rohitverma007 avatar nissy-dev avatar timocov avatar plantain-00 avatar jun-sheaf avatar shuirutian avatar ncoley avatar linusu avatar fabianopb avatar vincentbel avatar rreverser avatar jthoms1 avatar aksharpatel47 avatar marijnh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.