Conversation
Add ctor function test Add some notes and rename variable
| error(right, Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, idText(right)); | ||
| return errorType; | ||
| } | ||
| if (isAssignmentToReadonlyEntity(node as Expression, prop, assignmentKind)) { |
There was a problem hiding this comment.
I collapsed these three checks into one function because they are always called together.
| const isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent; | ||
| const isLocalParameterProperty = ctor === symbol.valueDeclaration.parent; | ||
| const isLocalThisPropertyAssignment = isAssignmentDeclaration && symbol.parent?.valueDeclaration === ctor.parent; | ||
| const isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration && symbol.parent?.valueDeclaration === ctor; |
There was a problem hiding this comment.
This one is this.x = whatever inside a JS constructor function?
There was a problem hiding this comment.
Yep. Any suggestions for making the variable name clearer?
There was a problem hiding this comment.
- isLocalThisPropertyAssignmentConstructorFunction
+ isLocalThisPropertyAssignmentInConstructorFunction?
| const isAssignmentDeclaration = isBinaryExpression(symbol.valueDeclaration); | ||
| const isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent; | ||
| const isLocalParameterProperty = ctor === symbol.valueDeclaration.parent; | ||
| const isLocalThisPropertyAssignment = isAssignmentDeclaration && symbol.parent?.valueDeclaration === ctor.parent; |
There was a problem hiding this comment.
This would be true inside any method, but we’ve already ensured we’re in a constructor 👍
weswigham
left a comment
There was a problem hiding this comment.
How's the user suite look?
@typescript-bot user test this
|
@typescript-bot user test this |
|
@weswigham Looks like the bot doesn't pay attention to sign off comments. |
|
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
|
Results are the same as yesterday's |
Add
@readonlyto jsdoc; works the same way readonly does in TS.Fixes #17233