-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing property fix #14097
Missing property fix #14097
Conversation
const binaryExpression = token.parent.parent as BinaryExpression; | ||
|
||
const checker = context.program.getTypeChecker(); | ||
const widenedType = checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right)); |
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.
you also want to widen it. i.e. null
=> any
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.
Looks good. just add the getWidenedType
call
}] | ||
}, | ||
{ | ||
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_accessor_for_missing_property_0), [token.getText()]), |
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.
- "index accessor" -> "index signature"
- You either need a test for this fix, or you should get rid of it.
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.
changed and test added
@aozgaa after merging in master please port this to release-2.2 |
Implements #13071.
Note that there is considerably more work to do for stubbing out missing methods if we want to do any type inference on the parameters. There are additionally issues with inferring type parameters for the stubbed method from its type arguments.
Thoughts @mhegazy @billti @DanielRosenwasser ?