Readonly support for jsdoc - #35790
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 👍
Wesley Wigham (weswigham)
left a comment
There was a problem hiding this comment.
How's the user suite look?
TypeScript Bot (@typescript-bot) user test this
|
TypeScript Bot (@typescript-bot) user test this |
|
Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized community code test suite on this PR at a1d3a3e. You can monitor the build here. It should now contribute to this PR's status checks. |
|
Wesley Wigham (@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