Fixing a few strict null errors

#60565
This commit is contained in:
Matt Bierner 2018-10-15 18:22:01 -07:00
parent a57e7abae2
commit 04c118d1d8
8 changed files with 20 additions and 10 deletions

View file

@ -479,6 +479,7 @@
"./vs/workbench/services/files/node/watcher/unix/watcher.ts",
"./vs/workbench/services/hash/common/hashService.ts",
"./vs/workbench/services/hash/node/hashService.ts",
"./vs/workbench/services/issue/common/issue.ts",
"./vs/workbench/services/jsonschemas/common/jsonValidationExtensionPoint.ts",
"./vs/workbench/services/keybinding/common/keybindingIO.ts",
"./vs/workbench/services/keybinding/common/keyboardMapper.ts",
@ -500,7 +501,14 @@
"./vs/workbench/services/themes/common/workbenchThemeService.ts",
"./vs/workbench/services/title/common/titleService.ts",
"./vs/workbench/services/workspace/common/workspaceEditing.ts",
"./vs/workbench/test/electron-browser/api/mock.ts"
"./vs/workbench/test/electron-browser/api/mock.ts",
"./vs/workbench/services/search/node/searchHistoryService.ts",
"./vs/workbench/services/extensions/node/extensionDescriptionRegistry.ts",
"./vs/workbench/parts/emmet/browser/actions/showEmmetCommands.ts",
"./vs/workbench/parts/comments/common/commentModel.ts",
"./vs/workbench/common/views.ts",
"./vs/workbench/common/theme.ts",
"./vs/platform/telemetry/browser/errorTelemetry.ts"
],
"exclude": [
"./typings/require-monaco.d.ts"

View file

@ -146,7 +146,10 @@ export default class ErrorTelemetry {
e.count = 1;
this._buffer.splice(~idx, 0, e);
} else {
this._buffer[idx].count += 1;
if (!this._buffer[idx].count) {
this._buffer[idx].count = 0;
}
this._buffer[idx].count! += 1;
}
if (this._flushHandle === -1) {

View file

@ -525,7 +525,7 @@ export class Themable extends Disposable {
// Subclasses to override
}
protected getColor(id: string, modify?: (color: Color, theme: ITheme) => Color): string {
protected getColor(id: string, modify?: (color: Color, theme: ITheme) => Color): string | null {
let color = this.theme.getColor(id);
if (color && modify) {

View file

@ -133,10 +133,9 @@ export interface IViewsRegistry {
getViews(loc: ViewContainer): IViewDescriptor[];
getView(id: string): IViewDescriptor;
getView(id: string): IViewDescriptor | null;
getAllViews(): IViewDescriptor[];
}
export const ViewsRegistry: IViewsRegistry = new class implements IViewsRegistry {
@ -194,7 +193,7 @@ export const ViewsRegistry: IViewsRegistry = new class implements IViewsRegistry
return this._views.get(loc) || [];
}
getView(id: string): IViewDescriptor {
getView(id: string): IViewDescriptor | null {
for (const viewContainer of this._viewContainer) {
const viewDescriptor = (this._views.get(viewContainer) || []).filter(v => v.id === id)[0];
if (viewDescriptor) {

View file

@ -127,7 +127,7 @@ export class CommentsModel {
}
private groupByResource(commentThreads: CommentThread[]): ResourceWithCommentThreads[] {
const resourceCommentThreads = [];
const resourceCommentThreads = [] as ResourceWithCommentThreads[];
const commentThreadsByResource = new Map<string, ResourceWithCommentThreads>();
for (const group of groupBy(commentThreads, CommentsModel._compareURIs)) {
commentThreadsByResource.set(group[0].resource, new ResourceWithCommentThreads(URI.parse(group[0].resource), group));

View file

@ -34,7 +34,7 @@ class ShowEmmetCommandsAction extends EditorAction {
public run(accessor: ServicesAccessor, editor: ICodeEditor): TPromise<void> {
const quickOpenService = accessor.get(IQuickOpenService);
quickOpenService.show(EMMET_COMMANDS_PREFIX);
return TPromise.as(null);
return TPromise.as(void 0);
}
}

View file

@ -60,7 +60,7 @@ export class ExtensionDescriptionRegistry {
return this._extensionsArr.slice(0);
}
public getExtensionDescription(extensionId: string): IExtensionDescription {
public getExtensionDescription(extensionId: string): IExtensionDescription | null {
if (!hasOwnProperty.call(this._extensionsMap, extensionId)) {
return null;
}

View file

@ -26,7 +26,7 @@ export class SearchHistoryService implements ISearchHistoryService {
}
public load(): ISearchHistoryValues {
let result: ISearchHistoryValues;
let result: ISearchHistoryValues | undefined;
const raw = this.storageService.get(SearchHistoryService.SEARCH_HISTORY_KEY, StorageScope.WORKSPACE);
if (raw) {