Skip to content

Commit 9ef3784

Browse files
committed
Add a new config file option "omitTrimmingComments"
1 parent 7d5fe37 commit 9ef3784

5 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎apps/api-extractor/src/api/ExtractorConfig.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ interface IExtractorConfigParameters {
106106
untrimmedFilePath: string;
107107
betaTrimmedFilePath: string;
108108
publicTrimmedFilePath: string;
109+
omitTrimmingComments: boolean;
109110
tsdocMetadataEnabled: boolean;
110111
tsdocMetadataFilePath: string;
111112
messages: IExtractorMessagesConfig;
@@ -181,6 +182,8 @@ export class ExtractorConfig {
181182
public readonly betaTrimmedFilePath: string;
182183
/** {@inheritDoc IConfigDtsRollup.publicTrimmedFilePath} */
183184
public readonly publicTrimmedFilePath: string;
185+
/** {@inheritDoc IConfigDtsRollup.omitTrimmingComments} */
186+
public readonly omitTrimmingComments: boolean;
184187

185188
/** {@inheritDoc IConfigTsdocMetadata.enabled} */
186189
public readonly tsdocMetadataEnabled: boolean;
@@ -210,6 +213,7 @@ export class ExtractorConfig {
210213
this.untrimmedFilePath = parameters.untrimmedFilePath;
211214
this.betaTrimmedFilePath = parameters.betaTrimmedFilePath;
212215
this.publicTrimmedFilePath = parameters.publicTrimmedFilePath;
216+
this.omitTrimmingComments = parameters.omitTrimmingComments;
213217
this.tsdocMetadataEnabled = parameters.tsdocMetadataEnabled;
214218
this.tsdocMetadataFilePath = parameters.tsdocMetadataFilePath;
215219
this.messages = parameters.messages;
@@ -609,6 +613,7 @@ export class ExtractorConfig {
609613
let untrimmedFilePath: string = '';
610614
let betaTrimmedFilePath: string = '';
611615
let publicTrimmedFilePath: string = '';
616+
let omitTrimmingComments: boolean = false;
612617

613618
if (configObject.dtsRollup) {
614619
rollupEnabled = !!configObject.dtsRollup.enabled;
@@ -618,6 +623,7 @@ export class ExtractorConfig {
618623
configObject.dtsRollup.betaTrimmedFilePath, tokenContext);
619624
publicTrimmedFilePath = ExtractorConfig._resolvePathWithTokens('publicTrimmedFilePath',
620625
configObject.dtsRollup.publicTrimmedFilePath, tokenContext);
626+
omitTrimmingComments = !!configObject.dtsRollup.omitTrimmingComments;
621627
}
622628

623629
return new ExtractorConfig({
@@ -637,6 +643,7 @@ export class ExtractorConfig {
637643
untrimmedFilePath,
638644
betaTrimmedFilePath,
639645
publicTrimmedFilePath,
646+
omitTrimmingComments,
640647
tsdocMetadataEnabled,
641648
tsdocMetadataFilePath,
642649
messages: configObject.messages || { },

‎apps/api-extractor/src/api/IConfigFile.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ export interface IConfigDtsRollup {
171171
* prepend a folder token such as `<projectFolder>`.
172172
*/
173173
publicTrimmedFilePath?: string;
174+
175+
/**
176+
* When a declaration is trimmed, by default it will be replaced by a code comment such as
177+
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
178+
* declaration completely.
179+
*/
180+
omitTrimmingComments?: boolean;
174181
}
175182

176183
/**

‎apps/api-extractor/src/schemas/api-extractor-defaults.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
2727
"betaTrimmedFilePath": "",
28-
"publicTrimmedFilePath": ""
28+
"publicTrimmedFilePath": "",
29+
"omitTrimmingComments": false
2930
},
3031

3132
"tsdocMetadata": {

‎apps/api-extractor/src/schemas/api-extractor-template.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@
210210
* DEFAULT VALUE: ""
211211
*/
212212
// "publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts",
213+
214+
/**
215+
* When a declaration is trimmed, by default it will be replaced by a code comment such as
216+
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
217+
* declaration completely.
218+
*
219+
* DEFAULT VALUE: false
220+
*/
221+
// "omitTrimmingComments": true
213222
},
214223

215224
/**

‎apps/api-extractor/src/schemas/api-extractor.schema.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
"publicTrimmedFilePath": {
109109
"description": "Specifies the output path for a .d.ts rollup file to be generated with trimming for a \"public\" release. This file will include only declarations that are marked as \"@public\". If the path is an empty string, then this file will not be written. The path is resolved relative to the folder of the config file that contains the setting; to change this, prepend a folder token such as \"<projectFolder>\".",
110110
"type": "string"
111+
},
112+
"omitTrimmingComments": {
113+
"description": "When a declaration is trimmed, by default it will be replaced by a code comment such as \"Excluded from this release type: exampleMember\". Set \"omitTrimmingComments\" to true to remove the declaration completely.",
114+
"type": "boolean"
111115
}
112116
},
113117
"required": [ "enabled" ],

0 commit comments

Comments
 (0)