mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Fix TS 2.3.1 Compiler Errors in VSCode src/workbench (#25249)
TS 2.3.1 introduced a breaking change by [switching to covariant types for callbacks](https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#covariance-in-callback-parameters). This change tries to fix these compiler errors in the workbench codebase
This commit is contained in:
@@ -327,7 +327,7 @@ export class ExtHostApiCommands {
|
||||
return undefined;
|
||||
}
|
||||
if (value.rejectReason) {
|
||||
return TPromise.wrapError(value.rejectReason);
|
||||
return TPromise.wrapError<types.WorkspaceEdit>(value.rejectReason);
|
||||
}
|
||||
let workspaceEdit = new types.WorkspaceEdit();
|
||||
for (let edit of value.edits) {
|
||||
|
||||
@@ -76,7 +76,7 @@ export class ExtHostCommands extends ExtHostCommandsShape {
|
||||
if (this._commands.has(id)) {
|
||||
// we stay inside the extension host and support
|
||||
// to pass any kind of parameters around
|
||||
return this.$executeContributedCommand(id, ...args);
|
||||
return this.$executeContributedCommand<T>(id, ...args);
|
||||
|
||||
} else {
|
||||
// automagically convert some argument types
|
||||
@@ -96,7 +96,7 @@ export class ExtHostCommands extends ExtHostCommandsShape {
|
||||
}
|
||||
});
|
||||
|
||||
return this._proxy.$executeCommand(id, args);
|
||||
return this._proxy.$executeCommand<T>(id, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ export class ExtHostDocuments extends ExtHostDocumentsShape {
|
||||
return this._documentsAndEditors.getDocument(uri.toString());
|
||||
}, err => {
|
||||
this._documentLoader.delete(uri.toString());
|
||||
return TPromise.wrapError(err);
|
||||
return TPromise.wrapError<ExtHostDocumentData>(err);
|
||||
});
|
||||
this._documentLoader.set(uri.toString(), promise);
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ export class ExtHostExtensionService extends AbstractExtensionService<ExtHostExt
|
||||
});
|
||||
}
|
||||
|
||||
protected _actualActivateExtension(extensionDescription: IExtensionDescription): TPromise<ActivatedExtension> {
|
||||
protected _actualActivateExtension(extensionDescription: IExtensionDescription): TPromise<ExtHostExtension> {
|
||||
return this._doActualActivateExtension(extensionDescription).then((activatedExtension) => {
|
||||
this._proxy.$onExtensionActivated(extensionDescription.id);
|
||||
return activatedExtension;
|
||||
@@ -307,10 +307,10 @@ export class ExtHostExtensionService extends AbstractExtensionService<ExtHostExt
|
||||
}, (errors: any[]) => {
|
||||
// Avoid failing with an array of errors, fail with a single error
|
||||
if (errors[0]) {
|
||||
return TPromise.wrapError(errors[0]);
|
||||
return TPromise.wrapError<ExtHostExtension>(errors[0]);
|
||||
}
|
||||
if (errors[1]) {
|
||||
return TPromise.wrapError(errors[1]);
|
||||
return TPromise.wrapError<ExtHostExtension>(errors[1]);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
@@ -355,7 +355,7 @@ function loadCommonJSModule<T>(modulePath: string): TPromise<T> {
|
||||
try {
|
||||
r = require.__$__nodeRequire<T>(modulePath);
|
||||
} catch (e) {
|
||||
return TPromise.wrapError(e);
|
||||
return TPromise.wrapError<T>(e);
|
||||
}
|
||||
return TPromise.as(r);
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ class RenameAdapter {
|
||||
rejectReason: err
|
||||
};
|
||||
}
|
||||
return TPromise.wrapError(err);
|
||||
return TPromise.wrapError<modes.WorkspaceEdit>(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -716,7 +716,7 @@ export class ExtHostLanguageFeatures extends ExtHostLanguageFeaturesShape {
|
||||
private _withAdapter<A, R>(handle: number, ctor: { new (...args: any[]): A }, callback: (adapter: A) => TPromise<R>): TPromise<R> {
|
||||
let adapter = this._adapter.get(handle);
|
||||
if (!(adapter instanceof ctor)) {
|
||||
return TPromise.wrapError(new Error('no adapter found'));
|
||||
return TPromise.wrapError<R>(new Error('no adapter found'));
|
||||
}
|
||||
return callback(<any>adapter);
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ export class ExtHostSCM {
|
||||
return sourceControl;
|
||||
}
|
||||
|
||||
$provideOriginalResource(sourceControlHandle: number, uri: URI): TPromise<URI> {
|
||||
$provideOriginalResource(sourceControlHandle: number, uri: URI): TPromise<vscode.Uri> {
|
||||
const sourceControl = this._sourceControls.get(sourceControlHandle);
|
||||
|
||||
if (!sourceControl || !sourceControl.quickDiffProvider) {
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ExtHostStorage {
|
||||
}
|
||||
|
||||
getValue<T>(shared: boolean, key: string, defaultValue?: T): TPromise<T> {
|
||||
return this._proxy.$getValue(shared, key).then(value => value || defaultValue);
|
||||
return this._proxy.$getValue<T>(shared, key).then(value => value || defaultValue);
|
||||
}
|
||||
|
||||
setValue(shared: boolean, key: string, value: any): TPromise<void> {
|
||||
|
||||
@@ -513,7 +513,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
private _runOnProxy(callback: () => TPromise<any>, silent: boolean): TPromise<ExtHostTextEditor> {
|
||||
if (this._disposed) {
|
||||
if (!silent) {
|
||||
return TPromise.wrapError(silent);
|
||||
return TPromise.wrapError<ExtHostTextEditor>(silent);
|
||||
} else {
|
||||
console.warn('TextEditor is closed/disposed');
|
||||
return TPromise.as(undefined);
|
||||
@@ -521,7 +521,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
}
|
||||
return callback().then(() => this, err => {
|
||||
if (!silent) {
|
||||
return TPromise.wrapError(silent);
|
||||
return TPromise.wrapError<ExtHostTextEditor>(silent);
|
||||
}
|
||||
console.warn(err);
|
||||
return undefined;
|
||||
|
||||
@@ -85,7 +85,7 @@ export class ExtHostTreeView extends ExtHostTreeViewShape {
|
||||
const provider = this._extNodeProviders[providerId];
|
||||
if (!provider) {
|
||||
const errMessage = localize('treeExplorer.notRegistered', 'No TreeExplorerNodeProvider with id \'{0}\' registered.', providerId);
|
||||
return TPromise.wrapError(errMessage);
|
||||
return TPromise.wrapError<InternalTreeExplorerNode>(errMessage);
|
||||
}
|
||||
|
||||
return asWinJsPromise(() => provider.provideRootNode()).then(extRootNode => {
|
||||
@@ -100,7 +100,7 @@ export class ExtHostTreeView extends ExtHostTreeViewShape {
|
||||
return internalRootNode;
|
||||
}, err => {
|
||||
const errMessage = localize('treeExplorer.failedToProvideRootNode', 'TreeExplorerNodeProvider \'{0}\' failed to provide root node.', providerId);
|
||||
return TPromise.wrapError(errMessage);
|
||||
return TPromise.wrapError<InternalTreeExplorerNode>(errMessage);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ export class ExtHostTreeView extends ExtHostTreeViewShape {
|
||||
const provider = this._extNodeProviders[providerId];
|
||||
if (!provider) {
|
||||
const errMessage = localize('treeExplorer.notRegistered', 'No TreeExplorerNodeProvider with id \'{0}\' registered.', providerId);
|
||||
return TPromise.wrapError(errMessage);
|
||||
return TPromise.wrapError<InternalTreeExplorerNode[]>(errMessage);
|
||||
}
|
||||
|
||||
const extNodeMap = this._extNodeMaps[providerId];
|
||||
|
||||
@@ -188,14 +188,14 @@ export class MainThreadEditors extends MainThreadEditorsShape {
|
||||
|
||||
$tryApplyEdits(id: string, modelVersionId: number, edits: ISingleEditOperation[], opts: IApplyEditsOptions): TPromise<boolean> {
|
||||
if (!this._documentsAndEditors.getEditor(id)) {
|
||||
return TPromise.wrapError('TextEditor disposed');
|
||||
return TPromise.wrapError<boolean>('TextEditor disposed');
|
||||
}
|
||||
return TPromise.as(this._documentsAndEditors.getEditor(id).applyEdits(modelVersionId, edits, opts));
|
||||
}
|
||||
|
||||
$tryInsertSnippet(id: string, template: string, ranges: IRange[], opts: IUndoStopOptions): TPromise<boolean> {
|
||||
if (!this._documentsAndEditors.getEditor(id)) {
|
||||
return TPromise.wrapError('TextEditor disposed');
|
||||
return TPromise.wrapError<boolean>('TextEditor disposed');
|
||||
}
|
||||
return TPromise.as(this._documentsAndEditors.getEditor(id).insertSnippet(template, ranges, opts));
|
||||
}
|
||||
@@ -212,7 +212,7 @@ export class MainThreadEditors extends MainThreadEditorsShape {
|
||||
const editor = this._documentsAndEditors.getEditor(id);
|
||||
|
||||
if (!editor) {
|
||||
return TPromise.wrapError('No such TextEditor');
|
||||
return TPromise.wrapError<ILineChange[]>('No such TextEditor');
|
||||
}
|
||||
|
||||
const codeEditor = editor.getCodeEditor();
|
||||
|
||||
@@ -33,7 +33,7 @@ export class MainThreadQuickOpen extends MainThreadQuickOpenShape {
|
||||
|
||||
const myToken = ++this._token;
|
||||
|
||||
this._contents = new TPromise((c, e) => {
|
||||
this._contents = new TPromise<MyQuickPickItems[]>((c, e) => {
|
||||
this._doSetItems = (items) => {
|
||||
if (myToken === this._token) {
|
||||
c(items);
|
||||
|
||||
@@ -27,7 +27,7 @@ export class MainThreadStorage extends MainThreadStorageShape {
|
||||
value = JSON.parse(jsonValue);
|
||||
return TPromise.as(value);
|
||||
} catch (err) {
|
||||
return TPromise.wrapError(err);
|
||||
return TPromise.wrapError<T>(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { ISearchService, QueryType } from 'vs/platform/search/common/search';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
@@ -45,7 +46,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
|
||||
this._textModelResolverService = textModelResolverService;
|
||||
}
|
||||
|
||||
$startSearch(include: string, exclude: string, maxResults: number, requestId: number): Thenable<Uri[]> {
|
||||
$startSearch(include: string, exclude: string, maxResults: number, requestId: number): Thenable<URI[]> {
|
||||
const workspace = this._contextService.getWorkspace();
|
||||
if (!workspace) {
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user