-
Notifications
You must be signed in to change notification settings - Fork 29.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TS 2.4 PromiseLike Errors With Async in VSCode Codebase #30216
Comments
@rbuckton or @andy-ms Can someone on the TS team please take a quick look at these errors? I've investigated but the error don't make much sense to me. I don't know where TS is getting the type This only started showing up in TS 2.4. My current thought is that we need to stop using |
Fixes microsoft#30216 **Bug** While compiling vscode with TS 2.4, there were around 10 errors reported about async functions that return a `TPromise`. **Fix** I'm checking with the TS team to see if these errors are expected or not. Until then, I believe we need to stop using `TPromise` with async functions. This change changes all instances that use `async` to instead use `then`.
Hi, it looks like you can get rid of the error by changing That said, the error was complaining about The reason you are just getting this error now in TS2.4 is due to microsoft/TypeScript#15104, since we are now checking the types inside of callbacks covariantly (previously it worked since |
In 2.4.1 we are stricter about the types for callbacks. It looks like the issue is the definition of export interface TValueCallback<T> {
(value: T | Thenable<T>): void;
} In general, we've made a number of improvements in the overall type definitions for the ES6
export declare class Promise<T = any, TProgress = any> {
constructor(
executor: (
resolve: (value: T | PromiseLike<T>) => void,
reject: (reason: any) => void,
progress: (progress: TProgress) => void) => void,
oncancel?: () => void);
public then<TResult1 = T, TResult2 = never>(
onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>,
onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>,
onprogress?: (progress: TProgress) => void): Promise<TResult1 | TResult2, TProgress>;
public done(
onfulfilled?: (value: T) => void,
onrejected?: (reason: any) => void,
onprogress?: (progress: TProgress) => void): void;
public cancel(): void;
public static as<T, TPromise extends PromiseLike<T>>(value: TPromise): TPromise;
public static as<T>(value: T): Promise<T>;
public static is(value: any): value is PromiseLike<any>;
public static timeout(delay: number): Promise<void>;
public static join<T>(promises: (T | PromiseLike<T>)[]): Promise<T[], { Key: string, Done: true }>;
public static join<T>(promises: { [n: string]: T | PromiseLike<T> }): Promise<{ [n: string]: T }, { Key: string, Done: true }>;
public static any<T>(promises: (T | PromiseLike<T>)[]): Promise<{ key: string; value: Promise<T>; }>;
public static wrap<T>(value: T | PromiseLike<T>): Promise<T>;
public static wrapError(error: Error): Promise<never>;
/**
* @internal
*/
public static addEventListener(event: 'error', promiseErrorHandler: (e: IPromiseError) => void);
}
export {
Promise as TPromise,
Promise as PPromise
}; I can submit a PR against VSCode for this if you would like. |
Thanks. The suggested @alexandrudima @jrieken @bpasero (Not sure of correct owners here. Please add anyone else that may have input) Can you please take a look at a Ron's other suggested changes to see if these are something we want to investigate |
Fixes microsoft#30216 Changes the TPromise callback interface as suggested by microsoft#30216 (comment) to fix async functions when compiling using ts 2.4+
This sounds good to me, but I'm sure @jrieken would like to give his $0.02 about that in the API. |
Fixes #30216 Changes the TPromise callback interface as suggested by #30216 (comment) to fix async functions when compiling using ts 2.4+
Building VSCode with TS 2.4, we're seeing about 10 errors in async functions around
TPromise
:Steps to reproduce
./scripts/npm install
The text was updated successfully, but these errors were encountered: