microsoft / microsoft/TypeScript
this is any type in class property assignment to function
Open
Nobody has claimed this yet.
Awaiting More Feedback
Domain: JavaScript
Suggestion
VS Code Tracked
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
From https://github.com/Microsoft/vscode/issues/30003
TypeScript Version: 2.4.1
Code
class AppComponent {
items = [ 'Angular 4', 'React', 'Underscore'];
foo = function () {
return this.items
}
}
Expected behavior:
The type of this in foo should be AppComponent
Actual behavior:
The type of this in foo is any
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided AppComponent reproduction and investigate how TypeScript infers this for a function assigned to a class property. Compare the expected AppComponent type with the actual any type, then verify the corrected inference using the same example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100