Skip to content

Commit bea9f5d

Browse files
authored
Add api-extractor (#1324)
* Add api-extractor; add api report for v9.1.1 * add api-extractor explanation to CONTRIBUTING.md
1 parent 5a8b203 commit bea9f5d

File tree

6 files changed

+587
-1
lines changed

6 files changed

+587
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ tsconfig.schemastore-schema.json
1111
/.vscode/
1212
/website/static/api
1313
/tsconfig.tsbuildinfo
14+
/temp

CONTRIBUTING.md

+7
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ We publish using `np`: https://npm.im/np
5050
4. Add changelog to the Github Release; match formatting from previous releases
5151
5. Merge `main` into `docs` (this automatically rebuilds the website)
5252
6. If tsconfig schema has changed, send a pull request to schemastore. [Example](https://github.com/SchemaStore/schemastore/pull/1208)
53+
54+
## APIExtractor
55+
56+
`npm run api-extractor` will update an API report generated by [`api-extractor`](https://api-extractor.com/pages/overview/intro/) which may be useful
57+
when generating release notes to detect (breaking) changes in our API surface.
58+
59+
I configured it for my own convenience; it is not a necessary part of our development process.

api-extractor.json

+368
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,368 @@
1+
/**
2+
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
3+
*/
4+
{
5+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
6+
7+
/**
8+
* Optionally specifies another JSON config file that this file extends from. This provides a way for
9+
* standard settings to be shared across multiple projects.
10+
*
11+
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
12+
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
13+
* resolved using NodeJS require().
14+
*
15+
* SUPPORTED TOKENS: none
16+
* DEFAULT VALUE: ""
17+
*/
18+
// "extends": "./shared/api-extractor-base.json"
19+
// "extends": "my-package/include/api-extractor-base.json"
20+
21+
/**
22+
* Determines the "<projectFolder>" token that can be used with other config file settings. The project folder
23+
* typically contains the tsconfig.json and package.json config files, but the path is user-defined.
24+
*
25+
* The path is resolved relative to the folder of the config file that contains the setting.
26+
*
27+
* The default value for "projectFolder" is the token "<lookup>", which means the folder is determined by traversing
28+
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
29+
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
30+
* will be reported.
31+
*
32+
* SUPPORTED TOKENS: <lookup>
33+
* DEFAULT VALUE: "<lookup>"
34+
*/
35+
// "projectFolder": "..",
36+
37+
/**
38+
* (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
39+
* analyzes the symbols exported by this module.
40+
*
41+
* The file extension must be ".d.ts" and not ".ts".
42+
*
43+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
44+
* prepend a folder token such as "<projectFolder>".
45+
*
46+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
47+
*/
48+
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts",
49+
50+
/**
51+
* A list of NPM package names whose exports should be treated as part of this package.
52+
*
53+
* For example, suppose that Webpack is used to generate a distributed bundle for the project "library1",
54+
* and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part
55+
* of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly
56+
* imports library2. To avoid this, we can specify:
57+
*
58+
* "bundledPackages": [ "library2" ],
59+
*
60+
* This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
61+
* local files for library1.
62+
*/
63+
"bundledPackages": [],
64+
65+
/**
66+
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
67+
*/
68+
"compiler": {
69+
/**
70+
* Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
71+
*
72+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
73+
* prepend a folder token such as "<projectFolder>".
74+
*
75+
* Note: This setting will be ignored if "overrideTsconfig" is used.
76+
*
77+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
78+
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
79+
*/
80+
// "tsconfigFilePath": "<projectFolder>/tsconfig.json",
81+
/**
82+
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
83+
* The object must conform to the TypeScript tsconfig schema:
84+
*
85+
* http://json.schemastore.org/tsconfig
86+
*
87+
* If omitted, then the tsconfig.json file will be read from the "projectFolder".
88+
*
89+
* DEFAULT VALUE: no overrideTsconfig section
90+
*/
91+
// "overrideTsconfig": {
92+
// . . .
93+
// }
94+
/**
95+
* This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended
96+
* and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when
97+
* dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses
98+
* for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck.
99+
*
100+
* DEFAULT VALUE: false
101+
*/
102+
// "skipLibCheck": true,
103+
},
104+
105+
/**
106+
* Configures how the API report file (*.api.md) will be generated.
107+
*/
108+
"apiReport": {
109+
/**
110+
* (REQUIRED) Whether to generate an API report.
111+
*/
112+
"enabled": true,
113+
114+
/**
115+
* The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce
116+
* a full file path.
117+
*
118+
* The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/".
119+
*
120+
* SUPPORTED TOKENS: <packageName>, <unscopedPackageName>
121+
* DEFAULT VALUE: "<unscopedPackageName>.api.md"
122+
*/
123+
"reportFileName": "<unscopedPackageName>.api.md",
124+
125+
/**
126+
* Specifies the folder where the API report file is written. The file name portion is determined by
127+
* the "reportFileName" setting.
128+
*
129+
* The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
130+
* e.g. for an API review.
131+
*
132+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
133+
* prepend a folder token such as "<projectFolder>".
134+
*
135+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
136+
* DEFAULT VALUE: "<projectFolder>/etc/"
137+
*/
138+
"reportFolder": "<projectFolder>/api-extractor/"
139+
140+
/**
141+
* Specifies the folder where the temporary report file is written. The file name portion is determined by
142+
* the "reportFileName" setting.
143+
*
144+
* After the temporary file is written to disk, it is compared with the file in the "reportFolder".
145+
* If they are different, a production build will fail.
146+
*
147+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
148+
* prepend a folder token such as "<projectFolder>".
149+
*
150+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
151+
* DEFAULT VALUE: "<projectFolder>/temp/"
152+
*/
153+
// "reportTempFolder": "<projectFolder>/temp/"
154+
},
155+
156+
/**
157+
* Configures how the doc model file (*.api.json) will be generated.
158+
*/
159+
"docModel": {
160+
/**
161+
* (REQUIRED) Whether to generate a doc model file.
162+
*/
163+
"enabled": false
164+
165+
/**
166+
* The output path for the doc model file. The file extension should be ".api.json".
167+
*
168+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
169+
* prepend a folder token such as "<projectFolder>".
170+
*
171+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
172+
* DEFAULT VALUE: "<projectFolder>/temp/<unscopedPackageName>.api.json"
173+
*/
174+
// "apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json"
175+
},
176+
177+
/**
178+
* Configures how the .d.ts rollup file will be generated.
179+
*/
180+
"dtsRollup": {
181+
/**
182+
* (REQUIRED) Whether to generate the .d.ts rollup file.
183+
*/
184+
"enabled": false
185+
186+
/**
187+
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.
188+
* This file will include all declarations that are exported by the main entry point.
189+
*
190+
* If the path is an empty string, then this file will not be written.
191+
*
192+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
193+
* prepend a folder token such as "<projectFolder>".
194+
*
195+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
196+
* DEFAULT VALUE: "<projectFolder>/dist/<unscopedPackageName>.d.ts"
197+
*/
198+
// "untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
199+
200+
/**
201+
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
202+
* This file will include only declarations that are marked as "@public" or "@beta".
203+
*
204+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
205+
* prepend a folder token such as "<projectFolder>".
206+
*
207+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
208+
* DEFAULT VALUE: ""
209+
*/
210+
// "betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
211+
212+
/**
213+
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
214+
* This file will include only declarations that are marked as "@public".
215+
*
216+
* If the path is an empty string, then this file will not be written.
217+
*
218+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
219+
* prepend a folder token such as "<projectFolder>".
220+
*
221+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
222+
* DEFAULT VALUE: ""
223+
*/
224+
// "publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts",
225+
226+
/**
227+
* When a declaration is trimmed, by default it will be replaced by a code comment such as
228+
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
229+
* declaration completely.
230+
*
231+
* DEFAULT VALUE: false
232+
*/
233+
// "omitTrimmingComments": true
234+
},
235+
236+
/**
237+
* Configures how the tsdoc-metadata.json file will be generated.
238+
*/
239+
"tsdocMetadata": {
240+
/**
241+
* Whether to generate the tsdoc-metadata.json file.
242+
*
243+
* DEFAULT VALUE: true
244+
*/
245+
"enabled": false
246+
/**
247+
* Specifies where the TSDoc metadata file should be written.
248+
*
249+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
250+
* prepend a folder token such as "<projectFolder>".
251+
*
252+
* The default value is "<lookup>", which causes the path to be automatically inferred from the "tsdocMetadata",
253+
* "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup
254+
* falls back to "tsdoc-metadata.json" in the package folder.
255+
*
256+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
257+
* DEFAULT VALUE: "<lookup>"
258+
*/
259+
// "tsdocMetadataFilePath": "<projectFolder>/dist/tsdoc-metadata.json"
260+
},
261+
262+
/**
263+
* Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
264+
* will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead.
265+
* To use the OS's default newline kind, specify "os".
266+
*
267+
* DEFAULT VALUE: "crlf"
268+
*/
269+
"newlineKind": "lf",
270+
271+
/**
272+
* Configures how API Extractor reports error and warning messages produced during analysis.
273+
*
274+
* There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
275+
*/
276+
"messages": {
277+
/**
278+
* Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing
279+
* the input .d.ts files.
280+
*
281+
* TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551"
282+
*
283+
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
284+
*/
285+
"compilerMessageReporting": {
286+
/**
287+
* Configures the default routing for messages that don't match an explicit rule in this table.
288+
*/
289+
"default": {
290+
/**
291+
* Specifies whether the message should be written to the the tool's output log. Note that
292+
* the "addToApiReportFile" property may supersede this option.
293+
*
294+
* Possible values: "error", "warning", "none"
295+
*
296+
* Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail
297+
* and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes
298+
* the "--local" option), the warning is displayed but the build will not fail.
299+
*
300+
* DEFAULT VALUE: "warning"
301+
*/
302+
"logLevel": "warning",
303+
304+
/**
305+
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
306+
* then the message will be written inside that file; otherwise, the message is instead logged according to
307+
* the "logLevel" option.
308+
*
309+
* DEFAULT VALUE: false
310+
*/
311+
"addToApiReportFile": true
312+
},
313+
314+
// "TS2551": {
315+
// "logLevel": "warning",
316+
// "addToApiReportFile": true
317+
// },
318+
//
319+
// . . .
320+
},
321+
322+
/**
323+
* Configures handling of messages reported by API Extractor during its analysis.
324+
*
325+
* API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag"
326+
*
327+
* DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings
328+
*/
329+
"extractorMessageReporting": {
330+
"default": {
331+
"logLevel": "warning",
332+
"addToApiReportFile": true
333+
},
334+
335+
"ae-missing-release-tag": {
336+
"logLevel": "none"
337+
}
338+
339+
// "ae-extra-release-tag": {
340+
// "logLevel": "warning",
341+
// "addToApiReportFile": true
342+
// },
343+
//
344+
// . . .
345+
},
346+
347+
/**
348+
* Configures handling of messages reported by the TSDoc parser when analyzing code comments.
349+
*
350+
* TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text"
351+
*
352+
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
353+
*/
354+
"tsdocMessageReporting": {
355+
"default": {
356+
"logLevel": "warning"
357+
// "addToApiReportFile": false
358+
}
359+
360+
// "tsdoc-link-tag-unescaped-text": {
361+
// "logLevel": "warning",
362+
// "addToApiReportFile": true
363+
// },
364+
//
365+
// . . .
366+
}
367+
}
368+
}

0 commit comments

Comments
 (0)