Skip to content

Commit 884f472

Browse files
committed
Adding an option to pass custom arguments to the tsc command.
1 parent d5e4425 commit 884f472

9 files changed

Lines changed: 60 additions & 9 deletions

File tree

‎common/reviews/api/gulp-core-build-typescript.api.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @public (undocumented)
22
interface ITscCmdTaskConfig extends IRSCTaskConfig {
3+
customArgs?: string[];
34
removeCommentsFromJavaScript?: boolean;
45
staticMatch?: string[];
56
}

‎common/reviews/api/rush-stack-compiler-2.4.api.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ interface ITslintRunnerConfig {
1414
fileWarning: WriteFileIssueFunction;
1515
}
1616

17+
// @beta (undocumented)
18+
interface ITypescriptCompilerOptions {
19+
customArgs?: string[];
20+
}
21+
1722
// @beta (undocumented)
1823
class RushStackCompilerBase<TOptions = {}> {
1924
constructor(taskOptions: TOptions, rootPath: string, terminalProvider: ITerminalProvider);
@@ -46,7 +51,7 @@ class TslintRunner extends RushStackCompilerBase<ITslintRunnerConfig> {
4651
}
4752

4853
// @beta (undocumented)
49-
class TypescriptCompiler extends RushStackCompilerBase {
54+
class TypescriptCompiler extends RushStackCompilerBase<ITypescriptCompilerOptions> {
5055
constructor(rootPath: string, terminalProvider: ITerminalProvider);
5156
// (undocumented)
5257
invoke(): Promise<void>;

‎common/reviews/api/rush-stack-compiler-2.7.api.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ interface ITslintRunnerConfig {
1414
fileWarning: WriteFileIssueFunction;
1515
}
1616

17+
// @beta (undocumented)
18+
interface ITypescriptCompilerOptions {
19+
customArgs?: string[];
20+
}
21+
1722
// @beta (undocumented)
1823
class RushStackCompilerBase<TOptions = {}> {
1924
constructor(taskOptions: TOptions, rootPath: string, terminalProvider: ITerminalProvider);
@@ -46,7 +51,7 @@ class TslintRunner extends RushStackCompilerBase<ITslintRunnerConfig> {
4651
}
4752

4853
// @beta (undocumented)
49-
class TypescriptCompiler extends RushStackCompilerBase {
54+
class TypescriptCompiler extends RushStackCompilerBase<ITypescriptCompilerOptions> {
5055
constructor(rootPath: string, terminalProvider: ITerminalProvider);
5156
// (undocumented)
5257
invoke(): Promise<void>;

‎common/reviews/api/rush-stack-compiler-2.9.api.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ interface ITslintRunnerConfig {
1414
fileWarning: WriteFileIssueFunction;
1515
}
1616

17+
// @beta (undocumented)
18+
interface ITypescriptCompilerOptions {
19+
customArgs?: string[];
20+
}
21+
1722
// @beta (undocumented)
1823
class RushStackCompilerBase<TOptions = {}> {
1924
constructor(taskOptions: TOptions, rootPath: string, terminalProvider: ITerminalProvider);
@@ -46,7 +51,7 @@ class TslintRunner extends RushStackCompilerBase<ITslintRunnerConfig> {
4651
}
4752

4853
// @beta (undocumented)
49-
class TypescriptCompiler extends RushStackCompilerBase {
54+
class TypescriptCompiler extends RushStackCompilerBase<ITypescriptCompilerOptions> {
5055
constructor(rootPath: string, terminalProvider: ITerminalProvider);
5156
// (undocumented)
5257
invoke(): Promise<void>;

‎common/reviews/api/rush-stack-compiler-3.0.api.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ interface ITslintRunnerConfig {
1414
fileWarning: WriteFileIssueFunction;
1515
}
1616

17+
// @beta (undocumented)
18+
interface ITypescriptCompilerOptions {
19+
customArgs?: string[];
20+
}
21+
1722
// @beta (undocumented)
1823
class RushStackCompilerBase<TOptions = {}> {
1924
constructor(taskOptions: TOptions, rootPath: string, terminalProvider: ITerminalProvider);
@@ -46,7 +51,7 @@ class TslintRunner extends RushStackCompilerBase<ITslintRunnerConfig> {
4651
}
4752

4853
// @beta (undocumented)
49-
class TypescriptCompiler extends RushStackCompilerBase {
54+
class TypescriptCompiler extends RushStackCompilerBase<ITypescriptCompilerOptions> {
5055
constructor(rootPath: string, terminalProvider: ITerminalProvider);
5156
// (undocumented)
5257
invoke(): Promise<void>;

‎common/reviews/api/rush-stack-compiler-3.1.api.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ interface ITslintRunnerConfig {
1414
fileWarning: WriteFileIssueFunction;
1515
}
1616

17+
// @beta (undocumented)
18+
interface ITypescriptCompilerOptions {
19+
customArgs?: string[];
20+
}
21+
1722
// @beta (undocumented)
1823
class RushStackCompilerBase<TOptions = {}> {
1924
constructor(taskOptions: TOptions, rootPath: string, terminalProvider: ITerminalProvider);
@@ -46,7 +51,7 @@ class TslintRunner extends RushStackCompilerBase<ITslintRunnerConfig> {
4651
}
4752

4853
// @beta (undocumented)
49-
class TypescriptCompiler extends RushStackCompilerBase {
54+
class TypescriptCompiler extends RushStackCompilerBase<ITypescriptCompilerOptions> {
5055
constructor(rootPath: string, terminalProvider: ITerminalProvider);
5156
// (undocumented)
5257
invoke(): Promise<void>;

‎core-build/gulp-core-build-typescript/src/TscCmdTask.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ import { TsParseConfigHost } from './TsParseConfigHost';
2323
* @public
2424
*/
2525
export interface ITscCmdTaskConfig extends IRSCTaskConfig {
26+
/**
27+
* Option to pass custom arguments to the tsc command.
28+
*/
29+
customArgs?: string[];
30+
2631
/**
2732
* Glob matches for files to be passed through the build.
2833
*/
@@ -92,6 +97,7 @@ export class TscCmdTask extends RSCTask<ITscCmdTaskConfig> {
9297
);
9398

9499
const typescriptCompiler: TTypescriptCompiler = new this._rushStackCompiler.TypescriptCompiler(
100+
{ customArgs: this.taskConfig.customArgs },
95101
this.buildFolder,
96102
this._terminalProvider
97103
);

‎libraries/load-themed-styles/gulpfile.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use strict';
22

33
const build = require('@microsoft/node-library-build');
4+
const path = require('path');
45

56
build.tscCmd = 'tsc-commonjs';
67

78
const tscAmdTask = new build.TscCmdTask();
89
tscAmdTask.name = 'tsc-amd';
10+
tscAmdTask.cleanMatch = [path.join(__dirname, 'lib-amd')];
911
tscAmdTask.setConfig({
1012
customArgs: [
1113
'--outDir', './lib-amd',
@@ -15,6 +17,7 @@ tscAmdTask.setConfig({
1517

1618
const tscEsnextTask = new build.TscCmdTask();
1719
tscEsnextTask.name = 'tsc-es6';
20+
tscEsnextTask.cleanMatch = [path.join(__dirname, 'lib-es6')];
1821
tscEsnextTask.setConfig({
1922
customArgs: [
2023
'--outDir', './lib-es6',

‎stack/rush-stack-compiler-shared/src/shared/TypescriptCompiler.ts‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,28 @@ import { RushStackCompilerBase } from './RushStackCompilerBase';
1212
/**
1313
* @beta
1414
*/
15-
export class TypescriptCompiler extends RushStackCompilerBase {
15+
export interface ITypescriptCompilerOptions {
16+
/**
17+
* Option to pass custom arguments to the tsc command.
18+
*/
19+
customArgs?: string[];
20+
}
21+
22+
/**
23+
* @beta
24+
*/
25+
export class TypescriptCompiler extends RushStackCompilerBase<ITypescriptCompilerOptions> {
1626
public typescript: typeof typescript = typescript;
1727
private _cmdRunner: CmdRunner;
1828

19-
constructor(rootPath: string, terminalProvider: ITerminalProvider) {
20-
super({}, rootPath, terminalProvider);
29+
constructor(rootPath: string, terminalProvider: ITerminalProvider);
30+
constructor(taskOptions: ITypescriptCompilerOptions, rootPath: string, terminalProvider: ITerminalProvider);
31+
constructor(arg1: ITypescriptCompilerOptions | string, arg2: string | ITerminalProvider, arg3?: ITerminalProvider) {
32+
super(
33+
typeof arg1 === 'string' ? {} : arg1,
34+
typeof arg2 === 'string' ? arg2 : arg1 as string,
35+
arg3 ? arg3 : arg2 as ITerminalProvider
36+
);
2137
this._cmdRunner = new CmdRunner(
2238
this._standardBuildFolders,
2339
this._terminal,
@@ -31,7 +47,7 @@ export class TypescriptCompiler extends RushStackCompilerBase {
3147

3248
public invoke(): Promise<void> {
3349
return this._cmdRunner.runCmd({
34-
args: [],
50+
args: this._taskOptions.customArgs || [],
3551
onData: (data: Buffer) => {
3652
// Log lines separately
3753
const dataLines: (string | undefined)[] = data.toString().split('\n');

0 commit comments

Comments
 (0)