Skip to content

Add related span pointing to this-shadowing location for implicitly-any this - #28299

Merged
Wesley Wigham (weswigham) merged 5 commits into
microsoft:masterfrom
weswigham:this-scope-errors
Nov 6, 2018
Merged

Wesley Wigham (weswigham) merged 5 commits into
microsoft:masterfrom
weswigham:this-scope-errors

Conversation

@weswigham

Copy link
Copy Markdown
Member

Fixes #26461

this.m();
~~~~
!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
!!! related TS2735 tests/cases/compiler/thisShadowingErrorSpans.ts:4:18: There is a 'this' type shadowed by this container.

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.

As a side note...I think we need better baselines for related information.. Just looking at this baseline first thing I see from message is I don't think message clearly states that its talking about f but then later I saw span. May be it would be good idea to use pretty formatting of related information instead because that's how its going to emerge anyways?

@weswigham Wesley Wigham (weswigham) Nov 2, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If you set the pretty flag in the test options, it actually does get recorded like that. I was told that it wasn't typically necessary though, esp. since pretty also has a bunch of formatting characters which don't translate to plaintext well.

Comment thread src/compiler/diagnosticMessages.json Resolved
Comment thread src/compiler/checker.ts Resolved
@weswigham
Wesley Wigham (weswigham) merged commit cc36e29 into microsoft:master Nov 6, 2018
@weswigham
Wesley Wigham (weswigham) deleted the this-scope-errors branch November 6, 2018 19:27
ghost pushed a commit that referenced this pull request Nov 7, 2018
…ny this (#28299)

* Add diagnostic pointing to this-shadowing location

* Fix almost-top-level-this case

* Change message on span
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants