FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Contextual typing of partially annotated signatures by ahejlsberg · Pull Request #11673 · microsoft/TypeScript · GitHub

Contextual typing of partially annotated signatures - #11673

Merged
Anders Hejlsberg (ahejlsberg) merged 6 commits into
masterfrom
partiallyAnnotatedSignatures
Oct 18, 2016
Merged

Contextual typing of partially annotated signatures#11673
Anders Hejlsberg (ahejlsberg) merged 6 commits into
masterfrom
partiallyAnnotatedSignatures

Conversation

Anders Hejlsberg (ahejlsberg) commented Oct 17, 2016
edited
Loading

Copy link
Copy Markdown
Member

This PR supersedes #11529 and #11600. Thanks to Herrington Darkholme (@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. Nathan Shively-Sanders (@sandersn) Maybe you want to look at that?

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

Copy link
Copy Markdown
Member

OK, I merged the tests from #11529.

Copy link
Copy Markdown
Member

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

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Anders Hejlsberg (ahejlsberg) deleted the partiallyAnnotatedSignatures branch October 18, 2016 00:39
Microsoft (microsoft) locked and limited conversation to collaborators Jun 19, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL