Skip to content

Commit ef74ad5

Browse files
committed
Introducing --skip-lib-check option to api-extractor.
1 parent e799364 commit ef74ad5

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

apps/api-extractor/src/cli/RunAction.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class RunAction extends CommandLineAction {
2929
private _configFileParameter: CommandLineStringParameter;
3030
private _localParameter: CommandLineFlagParameter;
3131
private _typescriptCompilerFolder: CommandLineStringParameter;
32+
private _skipLibCheck: CommandLineFlagParameter;
3233

3334
constructor(parser: ApiExtractorCommandLine) {
3435
super({
@@ -63,6 +64,15 @@ export class RunAction extends CommandLineAction {
6364
+ ' This can often cause compiler errors due to incompatibilities between different TS versions.'
6465
+ ' Use "--typescript-compiler-folder" to specify the folder path for your compiler version.'
6566
});
67+
68+
this._skipLibCheck = this.defineFlagParameter({
69+
parameterLongName: '--skip-lib-check',
70+
description: 'This flag causes the typechecker to be invoked with the --skipLibCheck option. This option is not'
71+
+ ' recommended and may cause api-extractor to produce incomplete or incorrect declarations, but it '
72+
+ ' may be required when dependencies contain declarations that are incompatible with newer versions'
73+
+ ' of TypeScript. If this option is used, it is strongly recommended that broken dependencies be'
74+
+ ' fixed or upgraded.'
75+
});
6676
}
6777

6878
protected onExecute(): Promise<void> { // override
@@ -124,7 +134,8 @@ export class RunAction extends CommandLineAction {
124134
config,
125135
{
126136
localBuild: this._localParameter.value,
127-
typescriptCompilerFolder: typescriptCompilerFolder
137+
typescriptCompilerFolder: typescriptCompilerFolder,
138+
skipLibCheck: this._skipLibCheck.value
128139
}
129140
);
130141

apps/api-extractor/src/extractor/Extractor.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ export interface IExtractorOptions {
7676
* @beta
7777
*/
7878
typescriptCompilerFolder?: string;
79+
80+
/**
81+
* This option causes the typechecker to be invoked with the --skipLibCheck option. This option is not
82+
* recommended and may cause api-extractor to produce incomplete or incorrect declarations, but it
83+
* may be required when dependencies contain declarations that are incompatible with newer versions
84+
* of TypeScript. If this option is used, it is strongly recommended that broken dependencies be
85+
* fixed or upgraded.
86+
*
87+
* @remarks
88+
* This option only applies when compiler.config.configType is set to "tsconfig"
89+
*
90+
* @beta
91+
*/
92+
skipLibCheck?: boolean;
7993
}
8094

8195
/**
@@ -192,6 +206,10 @@ export class Extractor {
192206
this._absoluteRootFolder
193207
);
194208

209+
if (!commandLine.options.skipLibCheck && options.skipLibCheck) {
210+
commandLine.options.skipLibCheck = true;
211+
}
212+
195213
this._updateCommandLineForTypescriptPackage(commandLine, options);
196214

197215
const normalizedEntryPointFile: string = path.normalize(

common/reviews/api/api-extractor.api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ interface IExtractorOptions {
215215
customLogger?: Partial<ILogger>;
216216
localBuild?: boolean;
217217
// @beta
218+
skipLibCheck?: boolean;
219+
// @beta
218220
typescriptCompilerFolder?: string;
219221
}
220222

0 commit comments

Comments
 (0)