Skip to content

Commit 6bf9cc1

Browse files
committed
Fixing more strict null errors
For microsoft#81574
1 parent 5d7dac3 commit 6bf9cc1

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

src/vs/workbench/services/search/node/fileSearch.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class FileWalker {
213213
onMessage({ message: rgCmd });
214214

215215
this.cmdResultCount = 0;
216-
this.collectStdout(cmd, 'utf8', onMessage, (err: Error, stdout?: string, last?: boolean) => {
216+
this.collectStdout(cmd, 'utf8', onMessage, (err: Error | null, stdout?: string, last?: boolean) => {
217217
if (err) {
218218
done(err);
219219
return;
@@ -300,7 +300,7 @@ export class FileWalker {
300300
*/
301301
readStdout(cmd: childProcess.ChildProcess, encoding: string, cb: (err: Error | null, stdout?: string) => void): void {
302302
let all = '';
303-
this.collectStdout(cmd, encoding, () => { }, (err: Error, stdout?: string, last?: boolean) => {
303+
this.collectStdout(cmd, encoding, () => { }, (err: Error | null, stdout?: string, last?: boolean) => {
304304
if (err) {
305305
cb(err);
306306
return;
@@ -547,12 +547,9 @@ export class FileWalker {
547547
return clb(null, undefined);
548548
});
549549
});
550-
}, (error: Error[]): void => {
551-
if (error) {
552-
error = arrays.coalesce(error); // find any error by removing null values first
553-
}
554-
555-
return done(error && error.length > 0 ? error[0] : undefined);
550+
}, (error: Array<Error | null> | null): void => {
551+
const filteredErrors = error ? arrays.coalesce(error) : error; // find any error by removing null values first
552+
return done(filteredErrors && filteredErrors.length > 0 ? filteredErrors[0] : undefined);
556553
});
557554
}
558555

@@ -622,8 +619,8 @@ export class Engine implements ISearchEngine<IRawFileMatch> {
622619
this.walker = new FileWalker(config);
623620
}
624621

625-
search(onResult: (result: IRawFileMatch) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error, complete: ISearchEngineSuccess) => void): void {
626-
this.walker.walk(this.folderQueries, this.extraFiles, onResult, onProgress, (err: Error, isLimitHit: boolean) => {
622+
search(onResult: (result: IRawFileMatch) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error | null, complete: ISearchEngineSuccess) => void): void {
623+
this.walker.walk(this.folderQueries, this.extraFiles, onResult, onProgress, (err: Error | null, isLimitHit: boolean) => {
627624
done(err, {
628625
limitHit: isLimitHit,
629626
stats: this.walker.getStats()

src/vs/workbench/test/browser/api/extHostDiagnostics.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers'
1212
import { mock } from 'vs/workbench/test/browser/api/mock';
1313
import { Emitter, Event } from 'vs/base/common/event';
1414
import { NullLogService } from 'vs/platform/log/common/log';
15+
import type * as vscode from 'vscode';
1516

1617
suite('ExtHostDiagnostics', () => {
1718

@@ -96,7 +97,7 @@ suite('ExtHostDiagnostics', () => {
9697
assert.throws(() => array.pop());
9798
assert.throws(() => array[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil'));
9899

99-
collection.forEach((uri, array: readonly Diagnostic[]) => {
100+
collection.forEach((uri: URI, array: readonly vscode.Diagnostic[]): any => {
100101
assert.throws(() => (array as Diagnostic[]).length = 0);
101102
assert.throws(() => (array as Diagnostic[]).pop());
102103
assert.throws(() => (array as Diagnostic[])[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil'));

0 commit comments

Comments
 (0)