提交 7dcedd17 编写于 作者: B Benjamin Pasero

debt - some TS fixes

上级 09b13663
......@@ -111,7 +111,7 @@ export function toDecodeStream(readable: Readable, options: IDecodeStreamOptions
});
}
_final(callback: (error: Error | null) => void) {
_final(callback: () => void) {
// normal finish
if (this.decodeStream) {
......
......@@ -398,7 +398,7 @@ function doWriteFileStreamAndFlush(path: string, reader: NodeJS.ReadableStream,
// not in some cache.
//
// See https://github.com/nodejs/node/blob/v5.10.0/lib/fs.js#L1194
function doWriteFileAndFlush(path: string, data: string | Buffer | Uint8Array, options: IEnsuredWriteFileOptions, callback: (error?: Error) => void): void {
function doWriteFileAndFlush(path: string, data: string | Buffer | Uint8Array, options: IEnsuredWriteFileOptions, callback: (error: Error | null) => void): void {
if (options.encoding) {
data = encode(data instanceof Uint8Array ? Buffer.from(data) : data, options.encoding.charset, { addBOM: options.encoding.addBOM });
}
......
......@@ -153,7 +153,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
this.logService.trace('ExtensionManagementService#zip', extension.identifier.id);
return this.collectFiles(extension)
.then(files => zip(path.join(tmpdir(), generateUuid()), files))
.then(path => URI.file(path));
.then<URI>(path => URI.file(path));
}
unzip(zipLocation: URI, type: ExtensionType): Promise<IExtensionIdentifier> {
......@@ -373,7 +373,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
return this.setUninstalled(extension)
.then(() => this.removeUninstalledExtension(extension)
.then(
() => this.installFromGallery(galleryExtension),
() => this.installFromGallery(galleryExtension).then(),
e => Promise.reject(new Error(nls.localize('removeError', "Error while removing the extension: {0}. Please Quit and Start VS Code before trying again.", toErrorMessage(e))))));
}
return Promise.reject(new Error(nls.localize('Not a Marketplace extension', "Only Marketplace Extensions can be reinstalled")));
......@@ -524,10 +524,10 @@ export class ExtensionManagementService extends Disposable implements IExtension
.then(galleryResult => {
const extensionsToInstall = galleryResult.firstPage;
return Promise.all(extensionsToInstall.map(e => this.installFromGallery(e)))
.then(() => null, errors => this.rollback(extensionsToInstall).then(() => Promise.reject(errors), () => Promise.reject(errors)));
.then(undefined, errors => this.rollback(extensionsToInstall).then(() => Promise.reject(errors), () => Promise.reject(errors)));
});
}
return null;
return;
});
}
}
......@@ -548,7 +548,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
.then(installed => {
const extensionToUninstall = installed.filter(e => areSameExtensions(e.identifier, extension.identifier))[0];
if (extensionToUninstall) {
return this.checkForDependenciesAndUninstall(extensionToUninstall, installed).then(() => null, error => Promise.reject(this.joinErrors(error)));
return this.checkForDependenciesAndUninstall(extensionToUninstall, installed).then(undefined, error => Promise.reject(this.joinErrors(error)));
} else {
return Promise.reject(new Error(nls.localize('notInstalled', "Extension '{0}' is not installed.", extension.manifest.displayName || extension.manifest.name)));
}
......
......@@ -41,7 +41,7 @@ export class LinuxUpdateService extends AbstractUpdateService {
this.setState(State.CheckingForUpdates(context));
this.requestService.request({ url: this.url }, CancellationToken.None)
.then<IUpdate>(asJson)
.then<IUpdate | null>(asJson)
.then(update => {
if (!update || !update.url || !update.version || !update.productVersion) {
this.telemetryService.publicLog2<{ explicit: boolean }, UpdateNotAvailableClassification>('update:notAvailable', { explicit: !!context });
......
......@@ -109,7 +109,7 @@ export class Win32UpdateService extends AbstractUpdateService {
this.setState(State.CheckingForUpdates(context));
this.requestService.request({ url: this.url }, CancellationToken.None)
.then<IUpdate>(asJson)
.then<IUpdate | null>(asJson)
.then(update => {
const updateType = getUpdateType();
......
......@@ -273,12 +273,13 @@ CommandsRegistry.registerCommand({
throw new Error(localize('id required', "Extension id required."));
}
const extensionManagementService = accessor.get(IExtensionManagementService);
const installed = await extensionManagementService.getInstalled(ExtensionType.User);
const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id }));
if (!extensionToUninstall) {
throw new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-vscode.csharp.", id));
}
try {
const installed = await extensionManagementService.getInstalled(ExtensionType.User);
const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id }));
if (!extensionToUninstall) {
return Promise.reject(new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-vscode.csharp.", id)));
}
await extensionManagementService.uninstall(extensionToUninstall, true);
} catch (e) {
onUnexpectedError(e);
......
......@@ -307,7 +307,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
// to have a size of 2 (1 running load and 1 queued load).
const queue = this.modelLoadQueue.queueFor(model.getResource());
if (queue.size <= 1) {
queue.queue(() => model.load().then<void>(undefined, onUnexpectedError));
queue.queue(() => model.load().then(undefined, onUnexpectedError));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册