提交 6bf9cc1e 编写于 作者: M Matt Bierner

Fixing more strict null errors

For #81574
上级 5d7dac35
...@@ -213,7 +213,7 @@ export class FileWalker { ...@@ -213,7 +213,7 @@ export class FileWalker {
onMessage({ message: rgCmd }); onMessage({ message: rgCmd });
this.cmdResultCount = 0; this.cmdResultCount = 0;
this.collectStdout(cmd, 'utf8', onMessage, (err: Error, stdout?: string, last?: boolean) => { this.collectStdout(cmd, 'utf8', onMessage, (err: Error | null, stdout?: string, last?: boolean) => {
if (err) { if (err) {
done(err); done(err);
return; return;
...@@ -300,7 +300,7 @@ export class FileWalker { ...@@ -300,7 +300,7 @@ export class FileWalker {
*/ */
readStdout(cmd: childProcess.ChildProcess, encoding: string, cb: (err: Error | null, stdout?: string) => void): void { readStdout(cmd: childProcess.ChildProcess, encoding: string, cb: (err: Error | null, stdout?: string) => void): void {
let all = ''; let all = '';
this.collectStdout(cmd, encoding, () => { }, (err: Error, stdout?: string, last?: boolean) => { this.collectStdout(cmd, encoding, () => { }, (err: Error | null, stdout?: string, last?: boolean) => {
if (err) { if (err) {
cb(err); cb(err);
return; return;
...@@ -547,12 +547,9 @@ export class FileWalker { ...@@ -547,12 +547,9 @@ export class FileWalker {
return clb(null, undefined); return clb(null, undefined);
}); });
}); });
}, (error: Error[]): void => { }, (error: Array<Error | null> | null): void => {
if (error) { const filteredErrors = error ? arrays.coalesce(error) : error; // find any error by removing null values first
error = arrays.coalesce(error); // find any error by removing null values first return done(filteredErrors && filteredErrors.length > 0 ? filteredErrors[0] : undefined);
}
return done(error && error.length > 0 ? error[0] : undefined);
}); });
} }
...@@ -622,8 +619,8 @@ export class Engine implements ISearchEngine<IRawFileMatch> { ...@@ -622,8 +619,8 @@ export class Engine implements ISearchEngine<IRawFileMatch> {
this.walker = new FileWalker(config); this.walker = new FileWalker(config);
} }
search(onResult: (result: IRawFileMatch) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error, complete: ISearchEngineSuccess) => void): void { search(onResult: (result: IRawFileMatch) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error | null, complete: ISearchEngineSuccess) => void): void {
this.walker.walk(this.folderQueries, this.extraFiles, onResult, onProgress, (err: Error, isLimitHit: boolean) => { this.walker.walk(this.folderQueries, this.extraFiles, onResult, onProgress, (err: Error | null, isLimitHit: boolean) => {
done(err, { done(err, {
limitHit: isLimitHit, limitHit: isLimitHit,
stats: this.walker.getStats() stats: this.walker.getStats()
......
...@@ -12,6 +12,7 @@ import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers' ...@@ -12,6 +12,7 @@ import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers'
import { mock } from 'vs/workbench/test/browser/api/mock'; import { mock } from 'vs/workbench/test/browser/api/mock';
import { Emitter, Event } from 'vs/base/common/event'; import { Emitter, Event } from 'vs/base/common/event';
import { NullLogService } from 'vs/platform/log/common/log'; import { NullLogService } from 'vs/platform/log/common/log';
import type * as vscode from 'vscode';
suite('ExtHostDiagnostics', () => { suite('ExtHostDiagnostics', () => {
...@@ -96,7 +97,7 @@ suite('ExtHostDiagnostics', () => { ...@@ -96,7 +97,7 @@ suite('ExtHostDiagnostics', () => {
assert.throws(() => array.pop()); assert.throws(() => array.pop());
assert.throws(() => array[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil')); assert.throws(() => array[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil'));
collection.forEach((uri, array: readonly Diagnostic[]) => { collection.forEach((uri: URI, array: readonly vscode.Diagnostic[]): any => {
assert.throws(() => (array as Diagnostic[]).length = 0); assert.throws(() => (array as Diagnostic[]).length = 0);
assert.throws(() => (array as Diagnostic[]).pop()); assert.throws(() => (array as Diagnostic[]).pop());
assert.throws(() => (array as Diagnostic[])[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil')); assert.throws(() => (array as Diagnostic[])[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil'));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册