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 — Make `this` in object literal always of type `any` by sandersn · Pull Request #8389 · microsoft/TypeScript

Conversation

@sandersn

@sandersn Nathan Shively-Sanders (sandersn) commented Apr 29, 2016

Copy link
Copy Markdown
Member

Fixes #8191 again, but re-breaks #8110 and #7801.

Previously, this was implicitly typed by the shape of its containing object literal.
This is not correct for JavaScript-style inheritance uses of object literals, and the previous fix was not correct either.
So we're going back to this: any in object literals for now.

Sorry, something went wrong.

Uh oh!

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

gdh1995 reacted with thumbs down emoji
All reactions
  • 👎 1 reaction
@sandersn
Make this in object literal always of type any
0a2ba0c
Previously, `this` was implicitly typed by the shape of its containing object literal.
This is not correct for JavaScript-style inheritance uses of object literals, and the previous fix was not correct either.
So we're going back to `this: any` in object literals for now.
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Apr 29, 2016
@sandersn

Nathan Shively-Sanders (sandersn) commented Apr 29, 2016

Copy link
Copy Markdown
Member Author

Anders Hejlsberg (@ahejlsberg) and Mohamed Hegazy (@mhegazy) here is the reversion to this:any in object literals. thisInObjectLiterals is the most interesting test since it specifically tests this case.

All reactions

Sorry, something went wrong.

Uh oh!

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

@mhegazy

Mohamed Hegazy (mhegazy) commented Apr 29, 2016

Copy link
Copy Markdown
Contributor

third time is a charm..

can we add a test for --noImplicitThis

All reactions

Sorry, something went wrong.

Uh oh!

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

@mhegazy

Mohamed Hegazy (mhegazy) commented Apr 29, 2016

Copy link
Copy Markdown
Contributor

👍

All reactions

Sorry, something went wrong.

Uh oh!

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

@sandersn
Add --noImplicitThis test for object literals
8d45a73
@mhegazy Mohamed Hegazy (mhegazy) mentioned this pull request Apr 30, 2016
Object literal contextual typing where 'this' has type 'any' in lambda functions #8368
Closed
@sandersn
Nathan Shively-Sanders (sandersn) merged commit d1b60f8 into master Apr 30, 2016
@sandersn
Nathan Shively-Sanders (sandersn) deleted the make-object-literal-this-any-typed branch April 30, 2016 02:15
This was referenced Apr 30, 2016
this in function declarations inside object literals should be typed #8110
Closed
No referencing/intellisense fo nested properties/functions within class #7801
Closed
@FranklinWhale Franklin Tse (FranklinWhale) mentioned this pull request Dec 9, 2016
Option to make this in functions inside object literals typed #12785
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

No reviews

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.

Incorrect/overly strong this inference for POJOs

Uh oh!

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

3 participants

@sandersn @mhegazy @msftclas
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.