Skip to content
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

Regression on Promise Type Checking in Latest Insiders #15352

Closed
mjbvz opened this issue Apr 24, 2017 · 2 comments
Closed

Regression on Promise Type Checking in Latest Insiders #15352

mjbvz opened this issue Apr 24, 2017 · 2 comments
Labels
Breaking Change Would introduce errors in existing code VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Apr 24, 2017

From: microsoft/vscode#25215

TypeScript Version: 2.3.1-insiders0420

Code

Using es2015.lib.d.ts:

function foo(x: Promise<boolean>) {}

foo(new Promise(() => true))

Expected behavior:
This compiles fine with TS 2.2.2 and with the older insiders 2.3.1 release.

Actual behavior:
With the current insiders, we get: message: 'Argument of type 'Promise<{}>' is not assignable to parameter of type 'Promise<boolean>'. Type '{}' is not assignable to type 'boolean'.'

This is causing upwards of 230 compiler errors in the vscode codebase

Possible related to #15104

@mjbvz mjbvz added High Priority VS Code Tracked There is a VS Code equivalent to this issue labels Apr 24, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Apr 24, 2017

This is an intentional change to tighten the promise compatibility checking. in your call back, inference fails, and the result is {}; previously it was allowed to assign Promise<{}> to a Promise<boolean>, which is unsafe.

See https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#covariance-in-callback-parameters for more details

@mhegazy mhegazy added the Breaking Change Would introduce errors in existing code label Apr 24, 2017
@mjbvz
Copy link
Contributor Author

mjbvz commented Apr 24, 2017

Thanks. This change seems to make sense even though it will be a little painful to update our codebase for it. It was not entirely clear to me why the code was compiling in ts 2.2.2 case when I looked at the types and thought more about the problem.

// cc @bpasero

@mjbvz mjbvz closed this as completed Apr 24, 2017
mjbvz added a commit to mjbvz/vscode that referenced this issue Apr 24, 2017
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
mjbvz added a commit to microsoft/vscode that referenced this issue Apr 24, 2017
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
mjbvz added a commit to mjbvz/vscode that referenced this issue Apr 25, 2017
From: microsoft/TypeScript#15352

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
mjbvz added a commit to microsoft/vscode that referenced this issue Apr 25, 2017
From: microsoft/TypeScript#15352

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
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Breaking Change Would introduce errors in existing code VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

2 participants