GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Contextual typing of partially annotated signatures by ahejlsberg · Pull Request #11673 · microsoft/TypeScript

Conversation

@ahejlsberg

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

Uh oh!

There was an error while loading. Please reload this page.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aluanhaddad, HerringtonDarkholme, blakeembrey, yortus, and aaronbeall reacted with thumbs up emoji
All reactions
  • 👍 5 reactions
Anders Hejlsberg (ahejlsberg) added 3 commits October 16, 2016 17:28
@ahejlsberg
Improve contextual typing of partially annotated signatures
8094b2c
@ahejlsberg
Accept new baselines
808db07
@ahejlsberg
Fix lint error
6425f0c
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Oct 17, 2016
@ahejlsberg Anders Hejlsberg (ahejlsberg) changed the title Partially annotated signatures Contextual typing of partially annotated signatures Oct 17, 2016
@HerringtonDarkholme Herrington Darkholme (HerringtonDarkholme) mentioned this pull request Oct 17, 2016
Fix #4241, infer partially annotated function #11529
Closed
@HerringtonDarkholme @sandersn
Add partially annotated function tests
df58df1
@sandersn

Nathan Shively-Sanders (sandersn) commented Oct 17, 2016

Copy link
Copy Markdown
Member

OK, I merged the tests from #11529.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sandersn
Add fourslash test for contextually-typed this
8aa56c1
Regression test for #10972
@sandersn

Nathan Shively-Sanders (sandersn) commented Oct 17, 2016

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sandersn
Nathan Shively-Sanders (sandersn) approved these changes Oct 17, 2016
View reviewed changes

@sandersn Nathan Shively-Sanders (sandersn) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
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");

@sandersn Nathan Shively-Sanders (sandersn) Oct 17, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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))

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ahejlsberg
Address CR feedback
af52b63
mhegazy
Mohamed Hegazy (mhegazy) approved these changes Oct 17, 2016
View reviewed changes
@ahejlsberg
Anders Hejlsberg (ahejlsberg) merged commit 9cedb6a into master Oct 18, 2016
@ahejlsberg
Anders Hejlsberg (ahejlsberg) deleted the partiallyAnnotatedSignatures branch October 18, 2016 00:39
@mhegazy Mohamed Hegazy (mhegazy) mentioned this pull request Oct 18, 2016
Give correct info for contextually typed this #11600
Closed
@microsoft 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.

Reviewers

@sandersn Nathan Shively-Sanders (sandersn) sandersn approved these changes
+1 more reviewer
@mhegazy Mohamed Hegazy (mhegazy) mhegazy approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@ahejlsberg @sandersn @mhegazy @msftclas @HerringtonDarkholme
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.