Skip to content

Commit bdc9479

Browse files
committed
Strict null check storageService
1 parent ba97287 commit bdc9479

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/tsconfig.strictNullChecks.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@
446446
"./vs/platform/integrity/common/integrity.ts",
447447
"./vs/platform/integrity/node/integrityServiceImpl.ts",
448448
"./vs/platform/issue/common/issue.ts",
449+
"./vs/platform/issue/electron-main/issueService.ts",
449450
"./vs/platform/issue/node/issueIpc.ts",
450451
"./vs/platform/jsonschemas/common/jsonContributionRegistry.ts",
451452
"./vs/platform/keybinding/common/abstractKeybindingService.ts",
@@ -499,6 +500,7 @@
499500
"./vs/platform/statusbar/common/statusbar.ts",
500501
"./vs/platform/storage/common/storage.ts",
501502
"./vs/platform/storage/common/storageLegacyService.ts",
503+
"./vs/platform/storage/node/storageService.ts",
502504
"./vs/platform/telemetry/browser/errorTelemetry.ts",
503505
"./vs/platform/telemetry/common/telemetry.ts",
504506
"./vs/platform/telemetry/common/telemetryService.ts",

src/vs/platform/storage/node/storageService.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class StorageService extends Disposable implements IStorageService {
3333
private _hasErrors = false;
3434
get hasErrors(): boolean { return this._hasErrors; }
3535

36-
private bufferedStorageErrors: (string | Error)[] = [];
36+
private bufferedStorageErrors?: (string | Error)[] = [];
3737
private _onStorageError: Emitter<string | Error> = this._register(new Emitter<string | Error>());
3838
get onStorageError(): Event<string | Error> {
3939
if (Array.isArray(this.bufferedStorageErrors)) {
@@ -199,7 +199,7 @@ export class StorageService extends Disposable implements IStorageService {
199199
});
200200

201201
console.group(`Storage: Global (integrity: ${result[2]}, load: ${getDuration('willInitGlobalStorage', 'didInitGlobalStorage')}, path: ${this.globalStorageWorkspacePath})`);
202-
let globalValues = [];
202+
let globalValues: { key: string, value: string }[] = [];
203203
globalItems.forEach((value, key) => {
204204
globalValues.push({ key, value });
205205
});
@@ -209,7 +209,7 @@ export class StorageService extends Disposable implements IStorageService {
209209
console.log(globalItemsParsed);
210210

211211
console.group(`Storage: Workspace (integrity: ${result[3]}, load: ${getDuration('willInitWorkspaceStorage', 'didInitWorkspaceStorage')}, path: ${this.workspaceStoragePath})`);
212-
let workspaceValues = [];
212+
let workspaceValues: { key: string, value: string }[] = [];
213213
workspaceItems.forEach((value, key) => {
214214
workspaceValues.push({ key, value });
215215
});
@@ -295,7 +295,7 @@ export class DelegatingStorageService extends Disposable implements IStorageServ
295295
const globalKeyMarker = 'storage://global/';
296296

297297
window.addEventListener('storage', e => {
298-
if (startsWith(e.key, globalKeyMarker)) {
298+
if (e.key && startsWith(e.key, globalKeyMarker)) {
299299
const key = e.key.substr(globalKeyMarker.length);
300300

301301
this._onDidChangeStorage.fire({ key, scope: StorageScope.GLOBAL });
@@ -307,23 +307,26 @@ export class DelegatingStorageService extends Disposable implements IStorageServ
307307
return this.storageService as StorageService;
308308
}
309309

310-
get(key: string, scope: StorageScope, fallbackValue?: string): string {
310+
get(key: string, scope: StorageScope, fallbackValue: string): string;
311+
get(key: string, scope: StorageScope, fallbackValue?: string): string | undefined {
311312
if (scope === StorageScope.WORKSPACE && !this.useLegacyWorkspaceStorage) {
312313
return this.storageService.get(key, scope, fallbackValue);
313314
}
314315

315316
return this.storageLegacyService.get(key, this.convertScope(scope), fallbackValue);
316317
}
317318

318-
getBoolean(key: string, scope: StorageScope, fallbackValue?: boolean): boolean {
319+
getBoolean(key: string, scope: StorageScope, fallbackValue: boolean): boolean;
320+
getBoolean(key: string, scope: StorageScope, fallbackValue?: boolean): boolean | undefined {
319321
if (scope === StorageScope.WORKSPACE && !this.useLegacyWorkspaceStorage) {
320322
return this.storageService.getBoolean(key, scope, fallbackValue);
321323
}
322324

323325
return this.storageLegacyService.getBoolean(key, this.convertScope(scope), fallbackValue);
324326
}
325327

326-
getInteger(key: string, scope: StorageScope, fallbackValue?: number): number {
328+
getInteger(key: string, scope: StorageScope, fallbackValue: number): number;
329+
getInteger(key: string, scope: StorageScope, fallbackValue?: number): number | undefined {
327330
if (scope === StorageScope.WORKSPACE && !this.useLegacyWorkspaceStorage) {
328331
return this.storageService.getInteger(key, scope, fallbackValue);
329332
}

0 commit comments

Comments
 (0)