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

Promise.then with Any Return Type Produces Incorrect error #12725

Closed
mjbvz opened this issue Dec 7, 2016 · 0 comments · Fixed by #13487
Closed

Promise.then with Any Return Type Produces Incorrect error #12725

mjbvz opened this issue Dec 7, 2016 · 0 comments · Fixed by #13487
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Dec 7, 2016

From: microsoft/vscode#16819

TypeScript Version: 2.1.4-insiders.20161206

Code

interface CompletionItem {
	a(): number;
}

function func(item: CompletionItem): Promise<CompletionItem> {
	const temp: Promise<any> = null
	return Promise.resolve('abc').then(service => {
		return temp;
	});
}

Expected behavior:
No errors.

Actual behavior:
Error:

Type 'Promise<string>' is not assignable to type 'Promise<CompletionItem>'.
  Type 'string' is not assignable to type 'CompletionItem'.

I believe the error comes from then selecting the incorrect overload during compilation. Changing the type to Promise.resolve(3) changes the error message to Type Promise<number> is not...

@mhegazy mhegazy added the Bug A bug in TypeScript label Dec 16, 2016
@mhegazy mhegazy added this to the TypeScript 2.2 milestone Dec 16, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 15, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants