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

Contextual typing of partially annotated signatures #11673

Merged
merged 6 commits into from
Oct 18, 2016

Conversation

ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented Oct 17, 2016

This PR supersedes #11529 and #11600. Thanks to @HerringtonDarkholme for the original idea regarding type inference and contextual typing of partially annotated signatures.

We probably want to move the tests over from #11529. @sandersn Maybe you want to look at that?

Fixes #4241.
Fixes #9648.
Fixes #10850.
Fixes #10972.

@ahejlsberg ahejlsberg changed the title Partially annotated signatures Contextual typing of partially annotated signatures Oct 17, 2016
@sandersn
Copy link
Member

OK, I merged the tests from #11529.

@sandersn
Copy link
Member

I also merged in the fourslash test from #11600, which is a regression test for #10972.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment — there is a utility for checking the this parameter already.

// know that all parameters (including 'this') have type annotations and nothing is
// subject to contextual typing.
const parameter = firstOrUndefined(node.parameters);
return !(parameter && parameter.name.kind === SyntaxKind.Identifier && (<Identifier>parameter.name).text === "this");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be written as !parameterIsThisKeyword(firstOrUndefined(node.parameters))

@ahejlsberg ahejlsberg merged commit 9cedb6a into master Oct 18, 2016
@ahejlsberg ahejlsberg deleted the partiallyAnnotatedSignatures branch October 18, 2016 00:39
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants