Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Contextual typing of partially annotated signatures#11673

Merged
ahejlsberg merged 6 commits into
mastermicrosoft/TypeScript:masterfrom
partiallyAnnotatedSignaturesmicrosoft/TypeScript:partiallyAnnotatedSignaturesCopy head branch name to clipboard
Oct 18, 2016
Merged

Contextual typing of partially annotated signatures#11673
ahejlsberg merged 6 commits into
mastermicrosoft/TypeScript:masterfrom
partiallyAnnotatedSignaturesmicrosoft/TypeScript:partiallyAnnotatedSignaturesCopy head branch name to clipboard

Conversation

@ahejlsberg

@ahejlsberg ahejlsberg commented Oct 17, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

OK, I merged the tests from #11529.

@sandersn

Copy link
Copy Markdown
Member

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

@sandersn sandersn left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/compiler/checker.ts Outdated
// 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
Copy Markdown
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.