Skip to content

Commit

Permalink
Fix VSCode/Extensions for TS 2.3.1
Browse files Browse the repository at this point in the history
From: microsoft/TypeScript#15352

TS 2.3.1 introduced a breaking change around checking of generic types. This change tries to fix these compiler errors in the extensions codebase
  • Loading branch information
mjbvz committed Apr 24, 2017
1 parent e105d5c commit 27a285f
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion extensions/git/src/askpass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Askpass implements Disposable {

try {
this.server.listen(0);
this.portPromise = new Promise(c => this.server.on('listening', () => c(this.server.address().port)));
this.portPromise = new Promise<number>(c => this.server.on('listening', () => c(this.server.address().port)));
this.server.on('error', err => console.error(err));
} catch (err) {
this.enabled = false;
Expand Down
2 changes: 1 addition & 1 deletion extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ export class CommandCenter {
}

private async smartCommit(
getCommitMessage: () => Promise<string>,
getCommitMessage: () => Promise<string | undefined>,
opts?: CommitOptions
): Promise<boolean> {
if (!opts) {
Expand Down
6 changes: 3 additions & 3 deletions extensions/git/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function once<T>(event: Event<T>): Event<T> {
}

export function eventToPromise<T>(event: Event<T>): Promise<T> {
return new Promise(c => once(event)(c));
return new Promise<T>(c => once(event)(c));
}

// TODO@Joao: replace with Object.assign
Expand Down Expand Up @@ -104,11 +104,11 @@ export function groupBy<T>(arr: T[], fn: (el: T) => string): { [key: string]: T[
}

export function denodeify<R>(fn: Function): (...args) => Promise<R> {
return (...args) => new Promise((c, e) => fn(...args, (err, r) => err ? e(err) : c(r)));
return (...args) => new Promise<R>((c, e) => fn(...args, (err, r) => err ? e(err) : c(r)));
}

export function nfcall<R>(fn: Function, ...args): Promise<R> {
return new Promise((c, e) => fn(...args, (err, r) => err ? e(err) : c(r)));
return new Promise<R>((c, e) => fn(...args, (err, r) => err ? e(err) : c(r)));
}

export async function mkdirp(path: string, mode?: number): Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion extensions/php/src/features/utils/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class ThrottledDelayer<T> extends Delayer<Promise<T>> {
constructor(defaultDelay: number) {
super(defaultDelay);

this.throttler = new Throttler();
this.throttler = new Throttler<T>();
}

public trigger(promiseFactory: ITask<Promise<T>>, delay?: number): Promise<Promise<T>> {
Expand Down
8 changes: 5 additions & 3 deletions extensions/typescript/src/features/formattingProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ export default class TypeScriptFormattingProvider implements DocumentRangeFormat
if (!absPath) {
return Promise.resolve(Object.create(null));
}

const formatOptions = this.getFormatOptions(options);
const args: Proto.ConfigureRequestArguments = {
file: absPath,
formatOptions: this.getFormatOptions(options)
formatOptions: formatOptions
};
return this.client.execute('configure', args, token).then(_ => {
this.formatOptions[key] = args.formatOptions;
return args.formatOptions;
this.formatOptions[key] = formatOptions;
return formatOptions;
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/typescript/src/typescriptMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function activate(context: ExtensionContext): void {
window.onDidChangeActiveTextEditor(VersionStatus.showHideStatus, null, context.subscriptions);
client.onReady().then(() => {
context.subscriptions.push(ProjectStatus.create(client,
path => new Promise(resolve => setTimeout(() => resolve(clientHost.handles(path)), 750)),
path => new Promise<boolean>(resolve => setTimeout(() => resolve(clientHost.handles(path)), 750)),
context.workspaceState));
}, () => {
// Nothing to do here. The client did show a message;
Expand Down
2 changes: 1 addition & 1 deletion extensions/typescript/src/typescriptServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
if (localModulePath) {
tryShowRestart(localModulePath);
}
return localModulePath;
return localModulePath || '';
});
case MessageAction.useBundled:
return this.workspaceState.update(TypeScriptServiceClient.useWorkspaceTsdkStorageKey, false)
Expand Down
6 changes: 3 additions & 3 deletions extensions/typescript/src/utils/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Delayer<T> {

public defaultDelay: number;
private timeout: any; // Timer
private completionPromise: Promise<T> | null;
private completionPromise: Promise<T | null> | null;
private onSuccess: ((value?: T | Thenable<T>) => void) | null;
private task: ITask<T> | null;

Expand All @@ -25,7 +25,7 @@ export class Delayer<T> {
this.task = null;
}

public trigger(task: ITask<T>, delay: number = this.defaultDelay): Promise<T> {
public trigger(task: ITask<T>, delay: number = this.defaultDelay): Promise<T | null> {
this.task = task;
if (delay >= 0) {
this.cancelTimeout();
Expand Down Expand Up @@ -55,7 +55,7 @@ export class Delayer<T> {
return this.completionPromise;
}

public forceDelivery(): Promise<T> | null {
public forceDelivery(): Promise<T | null> | null {
if (!this.completionPromise) {
return null;
}
Expand Down

0 comments on commit 27a285f

Please sign in to comment.