Skip to content

Commit fe45a7d

Browse files
committed
Fix remaining strict null errors in build scripts
1 parent 5862b41 commit fe45a7d

11 files changed

Lines changed: 29 additions & 22 deletions

File tree

build/lib/compilation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function createCompile(src, build, emitError) {
3636
var opts = _.clone(getTypeScriptCompilerOptions(src));
3737
opts.inlineSources = !!build;
3838
opts.noFilesystemLookup = true;
39-
var ts = tsb.create(opts, true, null, function (err) { return reporter(err.toString()); });
39+
var ts = tsb.create(opts, true, undefined, function (err) { return reporter(err.toString()); });
4040
return function (token) {
4141
var utf8Filter = util.filter(function (data) { return /(\/|\\)test(\/|\\).*utf8/.test(data.path); });
4242
var tsFilter = util.filter(function (data) { return /\.ts$/.test(data.path); });
@@ -58,7 +58,7 @@ function createCompile(src, build, emitError) {
5858
sourceRoot: opts.sourceRoot
5959
}))
6060
.pipe(tsFilter.restore)
61-
.pipe(reporter.end(emitError));
61+
.pipe(reporter.end(!!emitError));
6262
return es.duplex(input, output);
6363
};
6464
}

build/lib/compilation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function createCompile(src: string, build: boolean, emitError?: boolean): (token
4141
opts.inlineSources = !!build;
4242
opts.noFilesystemLookup = true;
4343

44-
const ts = tsb.create(opts, true, null, err => reporter(err.toString()));
44+
const ts = tsb.create(opts, true, undefined, err => reporter(err.toString()));
4545

4646
return function (token?: util.ICancellationToken) {
4747

@@ -66,7 +66,7 @@ function createCompile(src: string, build: boolean, emitError?: boolean): (token
6666
sourceRoot: opts.sourceRoot
6767
}))
6868
.pipe(tsFilter.restore)
69-
.pipe(reporter.end(emitError));
69+
.pipe(reporter.end(!!emitError));
7070

7171
return es.duplex(input, output);
7272
};

build/lib/electron.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const root = path.dirname(path.dirname(__dirname));
1111

1212
function getElectronVersion() {
1313
const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8');
14+
// @ts-ignore
1415
const target = /^target "(.*)"$/m.exec(yarnrc)[1];
1516

1617
return target;
@@ -19,6 +20,7 @@ function getElectronVersion() {
1920
module.exports.getElectronVersion = getElectronVersion;
2021

2122
// returns 0 if the right version of electron is in .build/electron
23+
// @ts-ignore
2224
if (require.main === module) {
2325
const version = getElectronVersion();
2426
const versionFile = path.join(root, '.build', 'electron', 'version');

build/lib/extensions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ function sequence(streamProviders) {
211211
pop();
212212
return result;
213213
}
214-
function packageExtensionsStream(opts) {
215-
opts = opts || {};
214+
function packageExtensionsStream(optsIn) {
215+
var opts = optsIn || {};
216216
var localExtensionDescriptions = glob.sync('extensions/*/package.json')
217217
.map(function (manifestPath) {
218218
var extensionPath = path.dirname(path.join(root, manifestPath));

build/lib/extensions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function fromLocal(extensionPath: string, sourceMappingURLBase?: string): Stream
3434
}
3535
}
3636

37-
function fromLocalWebpack(extensionPath: string, sourceMappingURLBase: string): Stream {
37+
function fromLocalWebpack(extensionPath: string, sourceMappingURLBase: string | undefined): Stream {
3838
let result = es.through();
3939

4040
let packagedDependencies: string[] = [];
@@ -249,7 +249,7 @@ function sequence(streamProviders: { (): Stream }[]): Stream {
249249
if (streamProviders.length === 0) {
250250
result.emit('end');
251251
} else {
252-
const fn = streamProviders.shift();
252+
const fn = streamProviders.shift()!;
253253
fn()
254254
.on('end', function () { setTimeout(pop, 0); })
255255
.pipe(result, { end: false });
@@ -260,8 +260,8 @@ function sequence(streamProviders: { (): Stream }[]): Stream {
260260
return result;
261261
}
262262

263-
export function packageExtensionsStream(opts?: IPackageExtensionsOptions): NodeJS.ReadWriteStream {
264-
opts = opts || {};
263+
export function packageExtensionsStream(optsIn?: IPackageExtensionsOptions): NodeJS.ReadWriteStream {
264+
const opts = optsIn || {};
265265

266266
const localExtensionDescriptions = (<string[]>glob.sync('extensions/*/package.json'))
267267
.map(manifestPath => {

build/lib/optimize.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function optimizeTask(opts) {
124124
var resourcesStream = es.through(); // this stream will contain the resources
125125
var bundleInfoStream = es.through(); // this stream will contain bundleInfo.json
126126
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
127-
if (err) {
127+
if (err || !result) {
128128
return bundlesStream.emit('error', JSON.stringify(err));
129129
}
130130
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
@@ -163,7 +163,7 @@ function optimizeTask(opts) {
163163
var result = es.merge(loader(src, bundledFileHeader, bundleLoader), bundlesStream, otherSourcesStream, resourcesStream, bundleInfoStream);
164164
return result
165165
.pipe(sourcemaps.write('./', {
166-
sourceRoot: null,
166+
sourceRoot: undefined,
167167
addComment: true,
168168
includeContent: true
169169
}))
@@ -219,13 +219,13 @@ function uglifyWithCopyrights() {
219219
return es.duplex(input, output);
220220
}
221221
function minifyTask(src, sourceMapBaseUrl) {
222-
var sourceMappingURL = sourceMapBaseUrl && (function (f) { return sourceMapBaseUrl + "/" + f.relative + ".map"; });
222+
var sourceMappingURL = sourceMapBaseUrl ? (function (f) { return sourceMapBaseUrl + "/" + f.relative + ".map"; }) : undefined;
223223
return function (cb) {
224224
var jsFilter = filter('**/*.js', { restore: true });
225225
var cssFilter = filter('**/*.css', { restore: true });
226226
pump(gulp.src([src + '/**', '!' + src + '/**/*.map']), jsFilter, sourcemaps.init({ loadMaps: true }), uglifyWithCopyrights(), jsFilter.restore, cssFilter, minifyCSS({ reduceIdents: false }), cssFilter.restore, sourcemaps.write('./', {
227227
sourceMappingURL: sourceMappingURL,
228-
sourceRoot: null,
228+
sourceRoot: undefined,
229229
includeContent: true,
230230
addComment: true
231231
}), gulp.dest(src + '-min'), function (err) {

build/lib/optimize.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
188188
const bundleInfoStream = es.through(); // this stream will contain bundleInfo.json
189189

190190
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
191-
if (err) { return bundlesStream.emit('error', JSON.stringify(err)); }
191+
if (err || !result) { return bundlesStream.emit('error', JSON.stringify(err)); }
192192

193193
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
194194

@@ -237,7 +237,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
237237

238238
return result
239239
.pipe(sourcemaps.write('./', {
240-
sourceRoot: null,
240+
sourceRoot: undefined,
241241
addComment: true,
242242
includeContent: true
243243
}))
@@ -302,7 +302,7 @@ function uglifyWithCopyrights(): NodeJS.ReadWriteStream {
302302
}
303303

304304
export function minifyTask(src: string, sourceMapBaseUrl?: string): (cb: any) => void {
305-
const sourceMappingURL = sourceMapBaseUrl && (f => `${sourceMapBaseUrl}/${f.relative}.map`);
305+
const sourceMappingURL = sourceMapBaseUrl ? ((f: any) => `${sourceMapBaseUrl}/${f.relative}.map`) : undefined;
306306

307307
return cb => {
308308
const jsFilter = filter('**/*.js', { restore: true });
@@ -319,7 +319,7 @@ export function minifyTask(src: string, sourceMapBaseUrl?: string): (cb: any) =>
319319
cssFilter.restore,
320320
sourcemaps.write('./', {
321321
sourceMappingURL,
322-
sourceRoot: null,
322+
sourceRoot: undefined,
323323
includeContent: true,
324324
addComment: true
325325
}),

build/lib/reporter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function log() {
4545
var messages = errors
4646
.map(function (err) { return regex.exec(err); })
4747
.filter(function (match) { return !!match; })
48+
.map(function (x) { return x; })
4849
.map(function (_a) {
4950
var path = _a[1], line = _a[2], column = _a[3], message = _a[4];
5051
return ({ path: path, line: parseInt(line), column: parseInt(column), message: message });

build/lib/reporter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function log(): void {
5555
const messages = errors
5656
.map(err => regex.exec(err))
5757
.filter(match => !!match)
58+
.map(x => x as string[])
5859
.map(([, path, line, column, message]) => ({ path, line: parseInt(line), column: parseInt(column), message }));
5960

6061
try {

build/lib/treeshaking.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ function markNodes(languageService: ts.LanguageService, options: ITreeShakingOpt
448448
}
449449

450450
if (options.shakeLevel === ShakeLevel.ClassMembers && (ts.isClassDeclaration(declaration) || ts.isInterfaceDeclaration(declaration))) {
451-
enqueue_black(declaration.name);
451+
enqueue_black(declaration.name!);
452452

453453
for (let j = 0; j < declaration.members.length; j++) {
454454
const member = declaration.members[j];
@@ -635,7 +635,7 @@ function generateResult(languageService: ts.LanguageService, shakeLevel: ShakeLe
635635
/**
636636
* Returns the node's symbol and the `import` node (if the symbol resolved from a different module)
637637
*/
638-
function getRealNodeSymbol(checker: ts.TypeChecker, node: ts.Node): [ts.Symbol, ts.Declaration] {
638+
function getRealNodeSymbol(checker: ts.TypeChecker, node: ts.Node): [ts.Symbol | null, ts.Declaration | null] {
639639
/**
640640
* Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 }
641641
*/

0 commit comments

Comments
 (0)