Skip to content

Commit 6ccac22

Browse files
committed
Convert the rest of GCB to support StrictNullCnecks.
1 parent e765c5f commit 6ccac22

File tree

14 files changed

+111
-67
lines changed

14 files changed

+111
-67
lines changed

common/reviews/api/gulp-core-build-webpack.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface IWebpackTaskConfig {
99
// @public (undocumented)
1010
class WebpackTask extends GulpTask<IWebpackTaskConfig> {
1111
// (undocumented)
12-
public executeTask(gulp: gulp.Gulp, completeCallback: (result?: Object) => void): void;
12+
public executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): void;
1313
// (undocumented)
1414
public isEnabled(buildConfig: IBuildConfig): boolean;
1515
// (undocumented)

common/reviews/api/node-library-build.api.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export declare function addSuppression(str: string): void;
44
// @public
55
class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
66
// (undocumented)
7-
executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream;
7+
executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream | void;
88
// (undocumented)
99
loadSchema(): Object;
1010
// (undocumented)
@@ -16,13 +16,13 @@ class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
1616
// @public
1717
class CleanTask extends GulpTask<void> {
1818
constructor();
19-
executeTask(gulp: gulp.Gulp, completeCallback: (result?: Object) => void): void;
19+
executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): void;
2020
}
2121

2222
// @public
2323
class CopyTask extends GulpTask<ICopyConfig> {
2424
constructor();
25-
executeTask(gulp: gulp.Gulp, completeCallback: (result?: Object) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
25+
executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
2626
loadSchema(): Object;
2727
}
2828

@@ -47,7 +47,7 @@ export declare function functionalTestRun(name: string, result: TestResultState,
4747
// @public
4848
class GenerateShrinkwrapTask extends GulpTask<void> {
4949
constructor();
50-
executeTask(gulp: gulpType.Gulp, completeCallback: (result?: Object) => void): NodeJS.ReadWriteStream;
50+
executeTask(gulp: gulpType.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream | void;
5151
}
5252

5353
// @public
@@ -67,56 +67,56 @@ class GulpTask<TASK_CONFIG> implements IExecutable {
6767
copyFile(localSourcePath: string, localDestPath?: string): void;
6868
enabled: boolean;
6969
execute(config: IBuildConfig): Promise<void>;
70-
abstract executeTask(gulp: gulp.Gulp | GulpProxy, completeCallback?: (result?: Object) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
70+
abstract executeTask(gulp: gulp.Gulp | GulpProxy, completeCallback?: (error?: string) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
7171
fileError(filePath: string, line: number, column: number, errorCode: string, message: string): void;
7272
fileExists(localPath: string): boolean;
7373
fileWarning(filePath: string, line: number, column: number, warningCode: string, message: string): void;
7474
getCleanMatch(buildConfig: IBuildConfig, taskConfig?: TASK_CONFIG): string[];
7575
isEnabled(buildConfig: IBuildConfig): boolean;
76-
protected loadSchema(): Object;
76+
protected loadSchema(): Object | undefined;
7777
log(message: string): void;
7878
logError(message: string): void;
7979
logVerbose(message: string): void;
8080
logWarning(message: string): void;
8181
mergeConfig(taskConfig: TASK_CONFIG): void;
8282
name: string;
8383
onRegister(): void;
84-
readJSONSync(localPath: string): Object;
84+
readJSONSync(localPath: string): Object | undefined;
8585
replaceConfig(taskConfig: TASK_CONFIG): void;
8686
resolvePath(localPath: string): string;
87-
schema: Object;
87+
schema: Object | undefined;
8888
setConfig(taskConfig: TASK_CONFIG): void;
8989
taskConfig: TASK_CONFIG;
9090
}
9191

9292
// @public (undocumented)
9393
interface IBuildConfig {
94-
args?: {
94+
args: {
9595
[ name: string ]: string | boolean;
9696
}
9797
buildErrorIconPath?: string;
9898
buildSuccessIconPath?: string;
99-
distFolder?: string;
100-
gulp?: GulpProxy | gulp.Gulp;
99+
distFolder: string;
100+
gulp: GulpProxy | gulp.Gulp;
101101
isRedundantBuild?: boolean;
102102
libAMDFolder?: string;
103103
libES6Folder?: string;
104-
libFolder?: string;
104+
libFolder: string;
105105
onTaskEnd?: (taskName: string, duration: number[], error?: any) => void;
106106
onTaskStart?: (taskName: string) => void;
107-
packageFolder?: string;
108-
production?: boolean;
107+
packageFolder: string;
108+
production: boolean;
109109
properties?: {
110110
[ key: string ]: any;
111111
}
112112
relogIssues?: boolean;
113-
rootPath?: string;
113+
rootPath: string;
114114
shouldWarningsFailBuild?: boolean;
115115
showToast?: boolean;
116-
srcFolder?: string;
117-
tempFolder?: string;
116+
srcFolder: string;
117+
tempFolder: string;
118118
uniqueTasks?: IExecutable[];
119-
verbose?: boolean;
119+
verbose: boolean;
120120
}
121121

122122
// @public
@@ -130,7 +130,7 @@ interface ICopyConfig {
130130
// @public
131131
interface ICustomGulpTask {
132132
// (undocumented)
133-
(gulp: gulp.Gulp | GulpProxy, buildConfig: IBuildConfig, done: (failure?: Object) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
133+
(gulp: gulp.Gulp | GulpProxy, buildConfig: IBuildConfig, done?: (failure?: Object) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
134134
}
135135

136136
// @public (undocumented)
@@ -211,7 +211,7 @@ class TypeScriptConfiguration {
211211
// @public (undocumented)
212212
class TypeScriptTask extends GulpTask<ITypeScriptTaskConfig> {
213213
// (undocumented)
214-
executeTask(gulp: gulpType.Gulp, completeCallback: (result?: string) => void): void;
214+
executeTask(gulp: gulpType.Gulp, completeCallback: (error?: string) => void): void;
215215
// (undocumented)
216216
getCleanMatch(buildConfig: IBuildConfig, taskConfig?: ITypeScriptTaskConfig): string[];
217217
// (undocumented)
@@ -226,7 +226,7 @@ class TypeScriptTask extends GulpTask<ITypeScriptTaskConfig> {
226226
// @public
227227
class ValidateShrinkwrapTask extends GulpTask<void> {
228228
constructor();
229-
executeTask(gulp: gulpType.Gulp): NodeJS.ReadWriteStream;
229+
executeTask(gulp: gulpType.Gulp, completeCallback: (error: string) => void): NodeJS.ReadWriteStream | void;
230230
}
231231

232232
// @public

common/reviews/api/web-library-build.api.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export declare function addSuppression(str: string): void;
44
// @public
55
class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
66
// (undocumented)
7-
executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream;
7+
executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream | void;
88
// (undocumented)
99
loadSchema(): Object;
1010
// (undocumented)
@@ -16,13 +16,13 @@ class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
1616
// @public
1717
class CleanTask extends GulpTask<void> {
1818
constructor();
19-
executeTask(gulp: gulp.Gulp, completeCallback: (result?: Object) => void): void;
19+
executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): void;
2020
}
2121

2222
// @public
2323
class CopyTask extends GulpTask<ICopyConfig> {
2424
constructor();
25-
executeTask(gulp: gulp.Gulp, completeCallback: (result?: Object) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
25+
executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
2626
loadSchema(): Object;
2727
}
2828

@@ -47,7 +47,7 @@ export declare function functionalTestRun(name: string, result: TestResultState,
4747
// @public
4848
class GenerateShrinkwrapTask extends GulpTask<void> {
4949
constructor();
50-
executeTask(gulp: gulpType.Gulp, completeCallback: (result?: Object) => void): NodeJS.ReadWriteStream;
50+
executeTask(gulp: gulpType.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream | void;
5151
}
5252

5353
// @public
@@ -67,56 +67,56 @@ class GulpTask<TASK_CONFIG> implements IExecutable {
6767
copyFile(localSourcePath: string, localDestPath?: string): void;
6868
enabled: boolean;
6969
execute(config: IBuildConfig): Promise<void>;
70-
abstract executeTask(gulp: gulp.Gulp | GulpProxy, completeCallback?: (result?: Object) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
70+
abstract executeTask(gulp: gulp.Gulp | GulpProxy, completeCallback?: (error?: string) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
7171
fileError(filePath: string, line: number, column: number, errorCode: string, message: string): void;
7272
fileExists(localPath: string): boolean;
7373
fileWarning(filePath: string, line: number, column: number, warningCode: string, message: string): void;
7474
getCleanMatch(buildConfig: IBuildConfig, taskConfig?: TASK_CONFIG): string[];
7575
isEnabled(buildConfig: IBuildConfig): boolean;
76-
protected loadSchema(): Object;
76+
protected loadSchema(): Object | undefined;
7777
log(message: string): void;
7878
logError(message: string): void;
7979
logVerbose(message: string): void;
8080
logWarning(message: string): void;
8181
mergeConfig(taskConfig: TASK_CONFIG): void;
8282
name: string;
8383
onRegister(): void;
84-
readJSONSync(localPath: string): Object;
84+
readJSONSync(localPath: string): Object | undefined;
8585
replaceConfig(taskConfig: TASK_CONFIG): void;
8686
resolvePath(localPath: string): string;
87-
schema: Object;
87+
schema: Object | undefined;
8888
setConfig(taskConfig: TASK_CONFIG): void;
8989
taskConfig: TASK_CONFIG;
9090
}
9191

9292
// @public (undocumented)
9393
interface IBuildConfig {
94-
args?: {
94+
args: {
9595
[ name: string ]: string | boolean;
9696
}
9797
buildErrorIconPath?: string;
9898
buildSuccessIconPath?: string;
99-
distFolder?: string;
100-
gulp?: GulpProxy | gulp.Gulp;
99+
distFolder: string;
100+
gulp: GulpProxy | gulp.Gulp;
101101
isRedundantBuild?: boolean;
102102
libAMDFolder?: string;
103103
libES6Folder?: string;
104-
libFolder?: string;
104+
libFolder: string;
105105
onTaskEnd?: (taskName: string, duration: number[], error?: any) => void;
106106
onTaskStart?: (taskName: string) => void;
107-
packageFolder?: string;
108-
production?: boolean;
107+
packageFolder: string;
108+
production: boolean;
109109
properties?: {
110110
[ key: string ]: any;
111111
}
112112
relogIssues?: boolean;
113-
rootPath?: string;
113+
rootPath: string;
114114
shouldWarningsFailBuild?: boolean;
115115
showToast?: boolean;
116-
srcFolder?: string;
117-
tempFolder?: string;
116+
srcFolder: string;
117+
tempFolder: string;
118118
uniqueTasks?: IExecutable[];
119-
verbose?: boolean;
119+
verbose: boolean;
120120
}
121121

122122
// @public
@@ -130,7 +130,7 @@ interface ICopyConfig {
130130
// @public
131131
interface ICustomGulpTask {
132132
// (undocumented)
133-
(gulp: gulp.Gulp | GulpProxy, buildConfig: IBuildConfig, done: (failure?: Object) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
133+
(gulp: gulp.Gulp | GulpProxy, buildConfig: IBuildConfig, done?: (failure?: Object) => void): Promise<Object> | NodeJS.ReadWriteStream | void;
134134
}
135135

136136
// @public (undocumented)
@@ -219,7 +219,7 @@ class TypeScriptConfiguration {
219219
// @public (undocumented)
220220
class TypeScriptTask extends GulpTask<ITypeScriptTaskConfig> {
221221
// (undocumented)
222-
executeTask(gulp: gulpType.Gulp, completeCallback: (result?: string) => void): void;
222+
executeTask(gulp: gulpType.Gulp, completeCallback: (error?: string) => void): void;
223223
// (undocumented)
224224
getCleanMatch(buildConfig: IBuildConfig, taskConfig?: ITypeScriptTaskConfig): string[];
225225
// (undocumented)
@@ -234,7 +234,7 @@ class TypeScriptTask extends GulpTask<ITypeScriptTaskConfig> {
234234
// @public
235235
class ValidateShrinkwrapTask extends GulpTask<void> {
236236
constructor();
237-
executeTask(gulp: gulpType.Gulp): NodeJS.ReadWriteStream;
237+
executeTask(gulp: gulpType.Gulp, completeCallback: (error: string) => void): NodeJS.ReadWriteStream | void;
238238
}
239239

240240
// @public
@@ -249,7 +249,7 @@ export declare function watch(watchMatch: string | string[], task: IExecutable):
249249
// @public (undocumented)
250250
class WebpackTask extends GulpTask<IWebpackTaskConfig> {
251251
// (undocumented)
252-
executeTask(gulp: gulp.Gulp, completeCallback: (result?: Object) => void): void;
252+
executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): void;
253253
// (undocumented)
254254
isEnabled(buildConfig: IBuildConfig): boolean;
255255
// (undocumented)

core-build/gulp-core-build-sass/src/SassTask.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,14 @@ export class SassTask extends GulpTask<ISassTaskConfig> {
7878

7979
public executeTask(
8080
gulp: gulp.Gulp,
81-
completeCallback?: (result?: string) => void
81+
completeCallback: (error?: string) => void
8282
): Promise<{}> | NodeJS.ReadWriteStream | void {
8383

84+
if (!this.taskConfig.sassMatch) {
85+
completeCallback('taskConfig.sassMatch must be defined');
86+
return;
87+
}
88+
8489
/* tslint:disable:typedef */
8590
const autoprefixer = require('autoprefixer');
8691
const cssModules = require('postcss-modules');
@@ -125,7 +130,7 @@ export class SassTask extends GulpTask<ISassTaskConfig> {
125130
gulp: gulp.Gulp,
126131
srcPattern: string[],
127132
/* tslint:disable:no-any */
128-
completeCallback: (result?: any) => void,
133+
completeCallback: (error?: string) => void,
129134
postCSSPlugins: any[],
130135
/* tslint:enable:no-any */
131136
checkFile?: (file: gulpUtil.File) => void

core-build/gulp-core-build-typescript/src/ApiExtractorTask.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,27 @@ export class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
8787
return require('./schemas/api-extractor.schema.json');
8888
};
8989

90-
public executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream {
90+
public executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream | void {
9191
if (!this.taskConfig.enabled || !this._validateConfiguration()) {
9292
completeCallback();
9393
return;
9494
}
9595

96+
if (!this.taskConfig.entry) {
97+
completeCallback('taskConfig.entry must be defined');
98+
return;
99+
}
100+
101+
if (!this.taskConfig.apiJsonFolder) {
102+
completeCallback('taskConfig.apiJsonFolder must be defined');
103+
return;
104+
}
105+
106+
if (!this.taskConfig.apiReviewFolder) {
107+
completeCallback('taskConfig.apiReviewFolder must be defined');
108+
return;
109+
}
110+
96111
const entryPointFile: string = path.join(this.buildConfig.rootPath, this.taskConfig.entry);
97112
const typingsFilePath: string = path.join(this.buildConfig.rootPath, 'typings/tsd.d.ts');
98113
const otherFiles: string[] = fsx.existsSync(typingsFilePath) ? [typingsFilePath] : [];

core-build/gulp-core-build-typescript/src/TSLintTask.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,26 @@ export class TSLintTask extends GulpTask<ITSLintTaskConfig> {
113113
return require('./schemas/tslint.schema.json');
114114
}
115115

116-
public executeTask(gulp: gulpType.Gulp): NodeJS.ReadWriteStream {
116+
public executeTask(gulp: gulpType.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream | void {
117117
const taskScope: TSLintTask = this;
118118

119+
if (!this.taskConfig.sourceMatch) {
120+
completeCallback('taskConfig.sourceMatch must be defined');
121+
return;
122+
}
123+
124+
if (!this.taskConfig.reporter) {
125+
completeCallback('taskConfig.reporter must be defined');
126+
return;
127+
}
128+
119129
const activeLintRules: any = taskScope._loadLintRules(); // tslint:disable-line:no-any
120130

121131
// Write out the active lint rules for easier debugging
122132
if (!fs.existsSync(path.dirname(this._getTsLintFilepath()))) {
123133
fs.mkdirSync(path.dirname(this._getTsLintFilepath()));
124134
}
135+
125136
fs.writeFileSync(this._getTsLintFilepath(), JSON.stringify(activeLintRules, undefined, 2));
126137

127138
const cached = require('gulp-cache'); // tslint:disable-line
@@ -162,7 +173,8 @@ export class TSLintTask extends GulpTask<ITSLintTaskConfig> {
162173
file['tslint'] = result;
163174
/* tslint:enable:no-string-literal */
164175

165-
if (result.failureCount > 0) {
176+
// We can't get here if reporter is undefined
177+
if (result.failureCount > 0 && taskScope.taskConfig.reporter) {
166178
taskScope.taskConfig.reporter(result, file, taskScope.taskConfig);
167179
}
168180

core-build/gulp-core-build-typescript/src/TextTask.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class TextTask extends GulpTask<ITextTaskConfig> {
1717
textMatch: ['src/**/*.txt']
1818
};
1919

20-
public executeTask(gulp: gulpType.Gulp): NodeJS.ReadWriteStream {
20+
public executeTask(gulp: gulpType.Gulp): NodeJS.ReadWriteStream | void {
2121
/* tslint:disable:typedef */
2222
const merge = require('merge2');
2323
const texttojs = require('gulp-texttojs');

0 commit comments

Comments
 (0)