File tree Expand file tree Collapse file tree 12 files changed +116
-67
lines changed Expand file tree Collapse file tree 12 files changed +116
-67
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
2
3
+ ### Bug Fixes
4
+
5
+ - Fixed ` const ` variables not properly marked as ` const ` , #1866 .
6
+
3
7
## v0.22.11 (2022-01-18)
4
8
5
9
### Features
Original file line number Diff line number Diff line change @@ -930,19 +930,6 @@ function convertVariableAsFunction(
930
930
exportSymbol
931
931
) ;
932
932
setModifiers ( symbol , accessDeclaration , reflection ) ;
933
- // Does anyone care about this? I doubt it...
934
- if (
935
- declaration &&
936
- hasAllFlags ( symbol . flags , ts . SymbolFlags . BlockScopedVariable )
937
- ) {
938
- reflection . setFlag (
939
- ReflectionFlag . Const ,
940
- hasAllFlags (
941
- ( declaration || symbol . valueDeclaration ) . parent . flags ,
942
- ts . NodeFlags . Const
943
- )
944
- ) ;
945
- }
946
933
947
934
context . finalizeDeclarationReflection ( reflection , symbol , exportSymbol ) ;
948
935
@@ -1066,6 +1053,16 @@ function setModifiers(
1066
1053
hasAllFlags ( modifiers , ts . ModifierFlags . Abstract )
1067
1054
) ;
1068
1055
1056
+ if (
1057
+ reflection . kindOf ( ReflectionKind . Variable ) &&
1058
+ hasAllFlags ( symbol . flags , ts . SymbolFlags . BlockScopedVariable )
1059
+ ) {
1060
+ reflection . setFlag (
1061
+ ReflectionFlag . Const ,
1062
+ hasAllFlags ( declaration . parent . flags , ts . NodeFlags . Const )
1063
+ ) ;
1064
+ }
1065
+
1069
1066
// ReflectionFlag.Static happens when constructing the reflection.
1070
1067
// We don't have sufficient information here to determine if it ought to be static.
1071
1068
}
Original file line number Diff line number Diff line change 188
188
"kind" : 32 ,
189
189
"kindString" : " Variable" ,
190
190
"flags" : {
191
- "isPrivate" : true
191
+ "isPrivate" : true ,
192
+ "isConst" : true
192
193
},
193
194
"comment" : {
194
195
"shortText" : " A variable that is made private via comment."
205
206
"kind" : 32 ,
206
207
"kindString" : " Variable" ,
207
208
"flags" : {
208
- "isProtected" : true
209
+ "isProtected" : true ,
210
+ "isConst" : true
209
211
},
210
212
"comment" : {
211
213
"shortText" : " A variable that is made protected via comment."
Original file line number Diff line number Diff line change 188
188
"kind" : 32 ,
189
189
"kindString" : " Variable" ,
190
190
"flags" : {
191
- "isPrivate" : true
191
+ "isPrivate" : true ,
192
+ "isConst" : true
192
193
},
193
194
"comment" : {
194
195
"shortText" : " A variable that is made private via comment."
205
206
"kind" : 32 ,
206
207
"kindString" : " Variable" ,
207
208
"flags" : {
208
- "isProtected" : true
209
+ "isProtected" : true ,
210
+ "isConst" : true
209
211
},
210
212
"comment" : {
211
213
"shortText" : " A variable that is made protected via comment."
Original file line number Diff line number Diff line change 73
73
"name" : " x" ,
74
74
"kind" : 32 ,
75
75
"kindString" : " Variable" ,
76
- "flags" : {},
76
+ "flags" : {
77
+ "isConst" : true
78
+ },
77
79
"type" : {
78
80
"type" : " intrinsic" ,
79
81
"name" : " number"
206
208
"name" : " ActionSet" ,
207
209
"kind" : 32 ,
208
210
"kindString" : " Variable" ,
209
- "flags" : {},
211
+ "flags" : {
212
+ "isConst" : true
213
+ },
210
214
"type" : {
211
215
"type" : " reference" ,
212
216
"qualifiedName" : " ts.server.ActionSet" ,
Original file line number Diff line number Diff line change 105
105
"name" : " Member" ,
106
106
"kind" : 32 ,
107
107
"kindString" : " Variable" ,
108
- "flags" : {},
108
+ "flags" : {
109
+ "isConst" : true
110
+ },
109
111
"type" : {
110
112
"type" : " literal" ,
111
113
"value" : 1
117
119
"name" : " Module" ,
118
120
"kind" : 32 ,
119
121
"kindString" : " Variable" ,
120
- "flags" : {},
122
+ "flags" : {
123
+ "isConst" : true
124
+ },
121
125
"type" : {
122
126
"type" : " reference" ,
123
127
"id" : 29 ,
130
134
"name" : " TypedMember" ,
131
135
"kind" : 32 ,
132
136
"kindString" : " Variable" ,
133
- "flags" : {},
137
+ "flags" : {
138
+ "isConst" : true
139
+ },
134
140
"type" : {
135
141
"type" : " reference" ,
136
142
"id" : 29 ,
143
149
"name" : " TypedModule" ,
144
150
"kind" : 32 ,
145
151
"kindString" : " Variable" ,
146
- "flags" : {},
152
+ "flags" : {
153
+ "isConst" : true
154
+ },
147
155
"type" : {
148
156
"type" : " reference" ,
149
157
"id" : 29 ,
356
364
"name" : " default" ,
357
365
"kind" : 32 ,
358
366
"kindString" : " Variable" ,
359
- "flags" : {},
367
+ "flags" : {
368
+ "isConst" : true
369
+ },
360
370
"type" : {
361
371
"type" : " literal" ,
362
372
"value" : 5
386
396
"name" : " x" ,
387
397
"kind" : 32 ,
388
398
"kindString" : " Variable" ,
389
- "flags" : {},
399
+ "flags" : {
400
+ "isConst" : true
401
+ },
390
402
"type" : {
391
403
"type" : " literal" ,
392
404
"value" : 5
511
523
"name" : " a" ,
512
524
"kind" : 32 ,
513
525
"kindString" : " Variable" ,
514
- "flags" : {},
526
+ "flags" : {
527
+ "isConst" : true
528
+ },
515
529
"comment" : {
516
530
"shortText" : " A simple named export that will be exported from export.ts"
517
531
},
Original file line number Diff line number Diff line change 318
318
"name" : " all" ,
319
319
"kind" : 64 ,
320
320
"kindString" : " Function" ,
321
- "flags" : {
322
- "isConst" : true
323
- },
321
+ "flags" : {},
324
322
"signatures" : [
325
323
{
326
324
"id" : 100 ,
1544
1542
"name" : " variableFunction" ,
1545
1543
"kind" : 64 ,
1546
1544
"kindString" : " Function" ,
1547
- "flags" : {
1548
- "isConst" : true
1549
- },
1545
+ "flags" : {},
1550
1546
"signatures" : [
1551
1547
{
1552
1548
"id" : 84 ,
Original file line number Diff line number Diff line change 28
28
"name" : " export=" ,
29
29
"kind" : 64 ,
30
30
"kindString" : " Function" ,
31
- "flags" : {
32
- "isConst" : true
33
- },
31
+ "flags" : {},
34
32
"signatures" : [
35
33
{
36
34
"id" : 3 ,
536
534
"name" : " ColumnType" ,
537
535
"kind" : 32 ,
538
536
"kindString" : " Variable" ,
539
- "flags" : {},
537
+ "flags" : {
538
+ "isConst" : true
539
+ },
540
540
"comment" : {},
541
541
"type" : {
542
542
"type" : " reflection" ,
591
591
"name" : " usedFoo" ,
592
592
"kind" : 64 ,
593
593
"kindString" : " Function" ,
594
- "flags" : {
595
- "isConst" : true
596
- },
594
+ "flags" : {},
597
595
"signatures" : [
598
596
{
599
597
"id" : 8 ,
Original file line number Diff line number Diff line change 1053
1053
"name" : " Mixin1Func" ,
1054
1054
"kind" : 64 ,
1055
1055
"kindString" : " Function" ,
1056
- "flags" : {
1057
- "isConst" : true
1058
- },
1056
+ "flags" : {},
1059
1057
"signatures" : [
1060
1058
{
1061
1059
"id" : 20 ,
1158
1156
"name" : " Mixin2" ,
1159
1157
"kind" : 64 ,
1160
1158
"kindString" : " Function" ,
1161
- "flags" : {
1162
- "isConst" : true
1163
- },
1159
+ "flags" : {},
1164
1160
"signatures" : [
1165
1161
{
1166
1162
"id" : 34 ,
1273
1269
"name" : " Mixin3" ,
1274
1270
"kind" : 64 ,
1275
1271
"kindString" : " Function" ,
1276
- "flags" : {
1277
- "isConst" : true
1278
- },
1272
+ "flags" : {},
1279
1273
"signatures" : [
1280
1274
{
1281
1275
"id" : 52 ,
Original file line number Diff line number Diff line change 80
80
"name" : " BigIntLiteralType" ,
81
81
"kind" : 32 ,
82
82
"kindString" : " Variable" ,
83
- "flags" : {},
83
+ "flags" : {
84
+ "isConst" : true
85
+ },
84
86
"type" : {
85
87
"type" : " literal" ,
86
88
"value" : {
95
97
"name" : " NegativeBigIntLiteralType" ,
96
98
"kind" : 32 ,
97
99
"kindString" : " Variable" ,
98
- "flags" : {},
100
+ "flags" : {
101
+ "isConst" : true
102
+ },
99
103
"type" : {
100
104
"type" : " literal" ,
101
105
"value" : {
110
114
"name" : " negativeOne" ,
111
115
"kind" : 32 ,
112
116
"kindString" : " Variable" ,
113
- "flags" : {},
117
+ "flags" : {
118
+ "isConst" : true
119
+ },
114
120
"type" : {
115
121
"type" : " literal" ,
116
122
"value" : -1
122
128
"name" : " numArray" ,
123
129
"kind" : 32 ,
124
130
"kindString" : " Variable" ,
125
- "flags" : {},
131
+ "flags" : {
132
+ "isConst" : true
133
+ },
126
134
"type" : {
127
135
"type" : " array" ,
128
136
"elementType" : {
661
669
"name" : " x" ,
662
670
"kind" : 32 ,
663
671
"kindString" : " Variable" ,
664
- "flags" : {},
672
+ "flags" : {
673
+ "isConst" : true
674
+ },
665
675
"type" : {
666
676
"type" : " literal" ,
667
677
"value" : 1
843
853
"name" : " leadingRest" ,
844
854
"kind" : 32 ,
845
855
"kindString" : " Variable" ,
846
- "flags" : {},
856
+ "flags" : {
857
+ "isConst" : true
858
+ },
847
859
"type" : {
848
860
"type" : " tuple" ,
849
861
"elements" : [
870
882
"name" : " namedTuple" ,
871
883
"kind" : 32 ,
872
884
"kindString" : " Variable" ,
873
- "flags" : {},
885
+ "flags" : {
886
+ "isConst" : true
887
+ },
874
888
"type" : {
875
889
"type" : " tuple" ,
876
890
"elements" : [
901
915
"name" : " withOptionalElements" ,
902
916
"kind" : 32 ,
903
917
"kindString" : " Variable" ,
904
- "flags" : {},
918
+ "flags" : {
919
+ "isConst" : true
920
+ },
905
921
"type" : {
906
922
"type" : " tuple" ,
907
923
"elements" : [
932
948
"name" : " withRestType" ,
933
949
"kind" : 32 ,
934
950
"kindString" : " Variable" ,
935
- "flags" : {},
951
+ "flags" : {
952
+ "isConst" : true
953
+ },
936
954
"type" : {
937
955
"type" : " tuple" ,
938
956
"elements" : [
959
977
"name" : " withRestTypeNames" ,
960
978
"kind" : 32 ,
961
979
"kindString" : " Variable" ,
962
- "flags" : {},
980
+ "flags" : {
981
+ "isConst" : true
982
+ },
963
983
"type" : {
964
984
"type" : " tuple" ,
965
985
"elements" : [
1114
1134
"name" : " a" ,
1115
1135
"kind" : 32 ,
1116
1136
"kindString" : " Variable" ,
1117
- "flags" : {},
1137
+ "flags" : {
1138
+ "isConst" : true
1139
+ },
1118
1140
"type" : {
1119
1141
"type" : " typeOperator" ,
1120
1142
"operator" : " unique" ,
You can’t perform that action at this time.
0 commit comments