Fix #7590: Allow 'readonly' to be used in constructor parameters#8555
Conversation
|
Hi @Andy-MS, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
| Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, | ||
| Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async | Readonly, | ||
| AccessibilityModifier = Public | Private | Protected, | ||
| // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. |
There was a problem hiding this comment.
The term for this is a "parameter property", so maybe a better name for the flag would be ParameterPropertyModifier
| HasJsxSpreadAttribute = 1 << 30, | ||
|
|
||
| Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, | ||
| Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async | Readonly, |
There was a problem hiding this comment.
Do you still want to keep Readonly in ? since you have made a new flag ParameterPropertyModifier
There was a problem hiding this comment.
got cha, I got confused why it is here caz i thought it is not direct related with the bug.
|
I believe that TypeScript Spec should be updated to include this change |
| @@ -0,0 +1,13 @@ | |||
| class C { | |||
| constructor(readonly x: number) {} | |||
There was a problem hiding this comment.
also to clarify if it is just readonly without accessibility modifier, are we assuming it is public?
There was a problem hiding this comment.
Yep. This is the same as for properties. (class C { readonly x: number; })
|
Can you add a test for declaration emitter. i.e. |
|
Also a test for:
|
|
Please add the word doc updates to the spec as well. |
|
👍 |
|
I think it'd be better to just file a spec bug and assign it to me or Anders. |
…bilityModifier to detect parameter properties. This is a continuation of #8555.
Fixes #7590