Skip to content

Commit 2f253d2

Browse files
committed
Fixing a few more strict function type errors
For microsoft#81574
1 parent e6abf47 commit 2f253d2

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/vs/base/node/watcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { normalizeNFC } from 'vs/base/common/normalization';
1010
import { toDisposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
1111
import { exists, readdir } from 'vs/base/node/pfs';
1212

13-
export function watchFile(path: string, onChange: (type: 'changed' | 'deleted', path: string) => void, onError: (error: string) => void): IDisposable {
13+
export function watchFile(path: string, onChange: (type: 'added' | 'changed' | 'deleted', path: string) => void, onError: (error: string) => void): IDisposable {
1414
return doWatchNonRecursive({ path, isDirectory: false }, onChange, onError);
1515
}
1616

@@ -189,4 +189,4 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha
189189

190190
watcherDisposables = dispose(watcherDisposables);
191191
});
192-
}
192+
}

src/vs/base/test/common/event.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ suite('Event', function () {
174174
test('Debounce Event', function (done: () => void) {
175175
let doc = new Samples.Document3();
176176

177-
let onDocDidChange = Event.debounce(doc.onDidChange, (prev: string[], cur) => {
177+
let onDocDidChange = Event.debounce(doc.onDidChange, (prev: string[] | undefined, cur) => {
178178
if (!prev) {
179179
prev = [cur];
180180
} else if (prev.indexOf(cur) < 0) {

src/vs/platform/extensionManagement/common/extensionGalleryService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
580580
if (extension.assets.manifest) {
581581
return this.getAsset(extension.assets.manifest, {}, token)
582582
.then(asText)
583-
.then(JSON.parse);
583+
.then(text => text ? JSON.parse(text) : null);
584584
}
585585
return Promise.resolve(null);
586586
}
@@ -590,7 +590,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
590590
if (asset) {
591591
return this.getAsset(asset[1])
592592
.then(asText)
593-
.then(JSON.parse);
593+
.then(text => text ? JSON.parse(text) : null);
594594
}
595595
return Promise.resolve(null);
596596
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class GlobalStorageDatabaseChannel extends Disposable implements IServerC
8383

8484
// Listen for changes in global storage to send to listeners
8585
// that are listening. Use a debouncer to reduce IPC traffic.
86-
this._register(Event.debounce(this.storageMainService.onDidChangeStorage, (prev: IStorageChangeEvent[], cur: IStorageChangeEvent) => {
86+
this._register(Event.debounce(this.storageMainService.onDidChangeStorage, (prev: IStorageChangeEvent[] | undefined, cur: IStorageChangeEvent) => {
8787
if (!prev) {
8888
prev = [cur];
8989
} else {
@@ -161,7 +161,7 @@ export class GlobalStorageDatabaseChannelClient extends Disposable implements IS
161161
}
162162

163163
private registerListeners(): void {
164-
this.onDidChangeItemsOnMainListener = this.channel.listen('onDidChangeItems')((e: ISerializableItemsChangeEvent) => this.onDidChangeItemsOnMain(e));
164+
this.onDidChangeItemsOnMainListener = this.channel.listen<ISerializableItemsChangeEvent>('onDidChangeItems')((e: ISerializableItemsChangeEvent) => this.onDidChangeItemsOnMain(e));
165165
}
166166

167167
private onDidChangeItemsOnMain(e: ISerializableItemsChangeEvent): void {

src/vs/workbench/api/common/extHostQuickOpen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
160160
// ---- workspace folder picker
161161

162162
showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions, token = CancellationToken.None): Promise<WorkspaceFolder | undefined> {
163-
return this._commands.executeCommand('_workbench.pickWorkspaceFolder', [options]).then(async (selectedFolder: WorkspaceFolder) => {
163+
return this._commands.executeCommand<WorkspaceFolder>('_workbench.pickWorkspaceFolder', [options]).then(async (selectedFolder: WorkspaceFolder) => {
164164
if (!selectedFolder) {
165165
return undefined;
166166
}

0 commit comments

Comments
 (0)