You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add useDefineForClassFields flag for Set -> Define property declaration (#33509)
* Disallow property/accessor overrides
Unless the base property or accessor is abstract
* Disallow uninitialised property overrides
This causes quite a few test breaks. We'll probably want to revert many
of them by switching to the upcoming `declare x: number` syntax.
* Updates from design review + fix ancient bug
1. Don't error when overriding properties from interfaces.
2. Fix error when overriding methods with other things. This had no
tests so I assume that the code was always dead and never worked.
* Need to add a couple of errors and squash one
Will update after checking out other branch for a minute
* Everything works so far
Need to test properties initialised in constructor
* Check for constructor initialisation
* change error wording
* Improve error wording
* Add codefix to add missing 'declare'
* Always emit accessors in .d.ts files
* Allow 'declare' on any uninitialised property decl
* Undo code moves
* Let sleeping dogs lie
* Correctly set NodeFlags.Ambient
And simplify redundant parts of check.
* Remove more unneeded code
* Update baselines
* Update baselines
* Update baselines
* Ignore this-property assignments
* Fix base-in-interface check
* Do not error when base parent is interface
* Fix base interface check
* Add missed baselines
* Fix check
* Fix new errors in services
* Fix new errors in services
* Fix errors in testRunner
* Add flag and turn off errors when on
* Structure of new emit is correct, fake content
It is 'hi'.
* Basically right emit
* Fix one last unitialised property declaration
* Haha no I missed another one
* Fix whitespace back to CRLF
* Minor fix and code cleanup
* New test case
* Fix bug in isInitializedProperty
* Updates from design meeting.
1. Change flag name to useDefineForClassFields (and flip polarity).
2. Forbid ES3 + useDefineForClassFields (since there is no
defineProperty).
3. Forbid overriding an abstract property-with-initializer with an
accessor.
* Update baselines
* Object.defineProperty for methods too
Using code from Ron from his upcoming refactor of the factory functions.
* Update slow baselines
* Improve error message
* Update src/compiler/transformers/utilities.ts
Co-Authored-By: Andrew Branch <andrewbranch@users.noreply.github.com>
* Add test of computed properties
* Remove done TODO
Copy file name to clipboardExpand all lines: src/compiler/diagnosticMessages.json
+34-4Lines changed: 34 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2233,6 +2233,19 @@
2233
2233
"category": "Error",
2234
2234
"code": 2609
2235
2235
},
2236
+
"Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property.": {
2237
+
"category": "Error",
2238
+
"code": 2610
2239
+
},
2240
+
"Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor.": {
2241
+
"category": "Error",
2242
+
"code": 2611
2243
+
},
2244
+
"Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration.": {
2245
+
"category": "Error",
2246
+
"code": 2612
2247
+
},
2248
+
2236
2249
"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
2237
2250
"category": "Error",
2238
2251
"code": 2649
@@ -3112,6 +3125,10 @@
3112
3125
"category": "Error",
3113
3126
"code": 5047
3114
3127
},
3128
+
"Option '{0}' cannot be specified when option 'target' is 'ES3'.": {
3129
+
"category": "Error",
3130
+
"code": 5048
3131
+
},
3115
3132
"Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": {
3116
3133
"category": "Error",
3117
3134
"code": 5051
@@ -3966,6 +3983,10 @@
3966
3983
"Conflicts are in this file.": {
3967
3984
"category": "Message",
3968
3985
"code": 6201
3986
+
},
3987
+
"Project references may not form a circular graph. Cycle detected: {0}": {
3988
+
"category": "Error",
3989
+
"code": 6202
3969
3990
},
3970
3991
"'{0}' was also declared here.": {
3971
3992
"category": "Message",
@@ -4043,6 +4064,10 @@
4043
4064
"category": "Message",
4044
4065
"code": 6221
4045
4066
},
4067
+
"Emit class fields with Define instead of Set.": {
4068
+
"category": "Message",
4069
+
"code": 6222
4070
+
},
4046
4071
4047
4072
"Projects to reference": {
4048
4073
"category": "Message",
@@ -4052,10 +4077,7 @@
4052
4077
"category": "Message",
4053
4078
"code": 6302
4054
4079
},
4055
-
"Project references may not form a circular graph. Cycle detected: {0}": {
4056
-
"category": "Error",
4057
-
"code": 6202
4058
-
},
4080
+
4059
4081
"Composite projects may not disable declaration emit.": {
4060
4082
"category": "Error",
4061
4083
"code": 6304
@@ -5180,6 +5202,14 @@
5180
5202
"category": "Message",
5181
5203
"code": 95093
5182
5204
},
5205
+
"Prefix with 'declare'": {
5206
+
"category": "Message",
5207
+
"code": 95094
5208
+
},
5209
+
"Prefix all incorrect property declarations with 'declare'": {
5210
+
"category": "Message",
5211
+
"code": 95095
5212
+
},
5183
5213
5184
5214
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
0 commit comments