You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update README to match the new code
This should match better with the code after #1034.
* feedback
* link to contribution guidelines
* Update README.md
Co-authored-by: Nathan Shively-Sanders <[email protected]>
* Update README.md
Co-authored-by: Nathan Shively-Sanders <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+13-58
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ This tool is used to generate the web-based `lib.dom.d.ts` file which is include
6
6
7
7
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).
8
8
9
-
If the condition is met but still is not available here, first check the heuristics below and then please [file an issue](hthttps://github.com/microsoft/TypeScript-DOM-lib-generator/issues/new).
9
+
If the condition is met but still is not available here, first check the [contribution guidelines](#contribution-guidelines) below and then please [file an issue](hthttps://github.com/microsoft/TypeScript-DOM-lib-generator/issues/new).
10
10
11
11
## Build Instructions
12
12
@@ -42,82 +42,37 @@ The libraries available on `@types/` like `@types/web` require a [`"target"`](ht
42
42
43
43
## Contribution Guidelines
44
44
45
-
The `dom.generated.d.ts`, `webworker.generated.d.ts` and `dom.iterable.generated.d.ts` files from the TypeScript repo are used as baselines.
45
+
The files in the `baselines/` directory from the TypeScript repo are used as baselines.
46
46
For each pull request, we will run the script and compare the generated files with the baseline files.
47
47
In order to make the tests pass, please update the baseline as well in any pull requests.
48
48
49
-
It's recommended to first check which spec the wrong type belongs to. Say we are to update `IntersectionObserver` which belongs to [`Intersection Observer`](https://www.w3.org/TR/intersection-observer/) spec, and then we can do:
49
+
### When the type is missing
50
50
51
-
1. First check we have the spec name `Intersection Observer` in `inputfiles/idlSources.json`. If not, add it.
52
-
2. Run `npm run fetch-idl "Intersection Observer" && npm run build && npm run baseline-accept`.
51
+
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](https://developer.mozilla.org/). 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.)
53
52
54
-
If the above didn't fix the type issues, we can fix them via json files as a last resort.
55
-
There are three json files that are typically used to alter the type generation: `addedTypes.json`, `overridingTypes.json`, and `removedTypes.json`.
56
-
`comments.json` can used to add comments to the types.
57
-
Finally, `knownTypes.json` determine which types are available in a certain environment in case it couldn't be automatically determined.
53
+
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`.
58
54
59
-
The format of each file can be inferred from their existing content.
55
+
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.
60
56
61
-
The common steps to send a pull request are:
57
+
### When the type exists but is wrong
62
58
63
-
0. Open or refer to an issue in the [TypeScript repo](https://github.com/Microsoft/TypeScript) which might get moved back to this repo.
64
-
1. Update an IDL or add missing elements to `inputfiles/addedTypes.json`, overriding elements to `inputfiles/overridingTypes.json`, or elements to remove to `inputfiles/removedTypes.json`.
65
-
2. Run the build script locally to obtain new `dom.generated.d.ts` and `webworker.generated.d.ts`.
66
-
3. Update the files in the `baselines` folder using the newly generated files under `generated` folder (`npm run baseline-accept`).
59
+
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.
67
60
68
-
### What are the TypeScript team's heuristics for PRs to the DOM APIs
69
-
70
-
Changes to this repo can have pretty drastic ecosystem effects, because these types are included by default in TypeScript.
71
-
Due to this, we tend to be quite conservative with our approach to introducing changes.
72
-
To give you a sense of whether we will accept changes, you can use these heuristics to know up-front if we'll be open to merging.
73
-
74
-
#### Fixes
75
-
76
-
> For example, changing a type on a field, or nullability references
77
-
78
-
- Does the PR show examples of the changes being used in spec examples or reputable websites like MDN?
79
-
- Did this change come from an IDL update?
80
-
- Does the change appear to be high-impact on a well-used API?
81
-
- Would the changes introduce a lot of breaking changes to existing code? For example the large corpus of typed code in DefinitelyTyped.
82
-
83
-
#### Additions
84
-
85
-
> For example, adding a new spec or subsection via a new or updated IDL file
86
-
87
-
- Does the new objects or fields show up in [mdn/browser-compat-data](https://github.com/mdn/browser-compat-data)? If not, it's likely too soon.
88
-
- Is the IDL source from WHATWG?
89
-
- Are the additions available in at least two of [Firefox](https://searchfox.org/mozilla-central/search?q=&path=), [Safari](https://webkit-search.igalia.com/webkit/search?q=&path=) and Chromium?
90
-
- Is the IDL source from W3C?
91
-
- What stage of the [W3C process](https://en.wikipedia.org/wiki/World_Wide_Web_Consortium#Specification_maturation) is the proposal for these changes: We aim for Proposed recommendation, but can accept Candidate recommendation for stable looking proposals.
92
-
- If it's at Working draft the additions available in all three of Firefox, Safari and Chromium
93
-
- Could any types added at the global scope have naming conflicts?
94
-
- Are the new features going to be used by a lot of people?
95
-
96
-
#### Removals
97
-
98
-
> For example, removing a browser-specific section of code
99
-
100
-
- Do the removed objects or fields show up in [mdn/browser-compat-data](https://github.com/mdn/browser-compat-data)? If so, are they marked as deprecated?
101
-
- Does an internet search for the fields show results in blogs/recommendations?
102
-
- When was the deprecation (this can be hard to find) but was it at least 2 years ago if so?
103
-
104
-
## Build Instructions
61
+
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.
105
62
106
63
# This repo
107
64
108
65
## Code Structure
109
66
110
-
-`src/index.ts`: handles the emitting of the `.d.ts` files.
67
+
-`src/build.ts`: handles the emitting of the `.d.ts` files.
111
68
-`src/test.ts`: verifies the output by comparing the `generated/` and `baseline/` contents.
112
69
113
70
## Input Files
114
71
115
-
-`browser.webidl.preprocessed.json`: a JSON file generated by Microsoft Edge. **Do not edit this file**.
116
-
- Due to the different update schedules between Edge and TypeScript, this may not be the most up-to-date version of the spec.
117
72
-`mdn/apiDescriptions.json`: a JSON file generated by fetching API descriptions from [MDN](https://developer.mozilla.org/en-US/docs/Web/API). **Do not edit this file**.
118
-
-`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`.
119
-
-`overridingTypes.json`: types that are defined in the spec file but has a better or more up-to-date definitions in the json files.
120
-
-`removedTypes.json`: types that are defined in the spec file but should be removed.
73
+
-`addedTypes.jsonc`: types that should exist but are missing from the spec data.
74
+
-`overridingTypes.jsonc`: types that are defined in the spec but have TypeScript-friendly modifications in the json files.
75
+
-`removedTypes.jsonc`: types that are defined in the spec but should be removed.
121
76
-`comments.json`: comment strings to be embedded in the generated .js files.
122
77
-`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.
0 commit comments