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 11# Unreleased
22
3+ ### Bug Fixes
4+
5+ - Fixed ` const ` variables not properly marked as ` const ` , #1866 .
6+
37## v0.22.11 (2022-01-18)
48
59### Features
Original file line number Diff line number Diff line change @@ -930,19 +930,6 @@ function convertVariableAsFunction(
930930 exportSymbol
931931 ) ;
932932 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- }
946933
947934 context . finalizeDeclarationReflection ( reflection , symbol , exportSymbol ) ;
948935
@@ -1066,6 +1053,16 @@ function setModifiers(
10661053 hasAllFlags ( modifiers , ts . ModifierFlags . Abstract )
10671054 ) ;
10681055
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+
10691066 // ReflectionFlag.Static happens when constructing the reflection.
10701067 // We don't have sufficient information here to determine if it ought to be static.
10711068}
Original file line number Diff line number Diff line change 188188 "kind" : 32 ,
189189 "kindString" : " Variable" ,
190190 "flags" : {
191- "isPrivate" : true
191+ "isPrivate" : true ,
192+ "isConst" : true
192193 },
193194 "comment" : {
194195 "shortText" : " A variable that is made private via comment."
205206 "kind" : 32 ,
206207 "kindString" : " Variable" ,
207208 "flags" : {
208- "isProtected" : true
209+ "isProtected" : true ,
210+ "isConst" : true
209211 },
210212 "comment" : {
211213 "shortText" : " A variable that is made protected via comment."
Original file line number Diff line number Diff line change 188188 "kind" : 32 ,
189189 "kindString" : " Variable" ,
190190 "flags" : {
191- "isPrivate" : true
191+ "isPrivate" : true ,
192+ "isConst" : true
192193 },
193194 "comment" : {
194195 "shortText" : " A variable that is made private via comment."
205206 "kind" : 32 ,
206207 "kindString" : " Variable" ,
207208 "flags" : {
208- "isProtected" : true
209+ "isProtected" : true ,
210+ "isConst" : true
209211 },
210212 "comment" : {
211213 "shortText" : " A variable that is made protected via comment."
Original file line number Diff line number Diff line change 7373 "name" : " x" ,
7474 "kind" : 32 ,
7575 "kindString" : " Variable" ,
76- "flags" : {},
76+ "flags" : {
77+ "isConst" : true
78+ },
7779 "type" : {
7880 "type" : " intrinsic" ,
7981 "name" : " number"
206208 "name" : " ActionSet" ,
207209 "kind" : 32 ,
208210 "kindString" : " Variable" ,
209- "flags" : {},
211+ "flags" : {
212+ "isConst" : true
213+ },
210214 "type" : {
211215 "type" : " reference" ,
212216 "qualifiedName" : " ts.server.ActionSet" ,
Original file line number Diff line number Diff line change 105105 "name" : " Member" ,
106106 "kind" : 32 ,
107107 "kindString" : " Variable" ,
108- "flags" : {},
108+ "flags" : {
109+ "isConst" : true
110+ },
109111 "type" : {
110112 "type" : " literal" ,
111113 "value" : 1
117119 "name" : " Module" ,
118120 "kind" : 32 ,
119121 "kindString" : " Variable" ,
120- "flags" : {},
122+ "flags" : {
123+ "isConst" : true
124+ },
121125 "type" : {
122126 "type" : " reference" ,
123127 "id" : 29 ,
130134 "name" : " TypedMember" ,
131135 "kind" : 32 ,
132136 "kindString" : " Variable" ,
133- "flags" : {},
137+ "flags" : {
138+ "isConst" : true
139+ },
134140 "type" : {
135141 "type" : " reference" ,
136142 "id" : 29 ,
143149 "name" : " TypedModule" ,
144150 "kind" : 32 ,
145151 "kindString" : " Variable" ,
146- "flags" : {},
152+ "flags" : {
153+ "isConst" : true
154+ },
147155 "type" : {
148156 "type" : " reference" ,
149157 "id" : 29 ,
356364 "name" : " default" ,
357365 "kind" : 32 ,
358366 "kindString" : " Variable" ,
359- "flags" : {},
367+ "flags" : {
368+ "isConst" : true
369+ },
360370 "type" : {
361371 "type" : " literal" ,
362372 "value" : 5
386396 "name" : " x" ,
387397 "kind" : 32 ,
388398 "kindString" : " Variable" ,
389- "flags" : {},
399+ "flags" : {
400+ "isConst" : true
401+ },
390402 "type" : {
391403 "type" : " literal" ,
392404 "value" : 5
511523 "name" : " a" ,
512524 "kind" : 32 ,
513525 "kindString" : " Variable" ,
514- "flags" : {},
526+ "flags" : {
527+ "isConst" : true
528+ },
515529 "comment" : {
516530 "shortText" : " A simple named export that will be exported from export.ts"
517531 },
Original file line number Diff line number Diff line change 318318 "name" : " all" ,
319319 "kind" : 64 ,
320320 "kindString" : " Function" ,
321- "flags" : {
322- "isConst" : true
323- },
321+ "flags" : {},
324322 "signatures" : [
325323 {
326324 "id" : 100 ,
15441542 "name" : " variableFunction" ,
15451543 "kind" : 64 ,
15461544 "kindString" : " Function" ,
1547- "flags" : {
1548- "isConst" : true
1549- },
1545+ "flags" : {},
15501546 "signatures" : [
15511547 {
15521548 "id" : 84 ,
Original file line number Diff line number Diff line change 2828 "name" : " export=" ,
2929 "kind" : 64 ,
3030 "kindString" : " Function" ,
31- "flags" : {
32- "isConst" : true
33- },
31+ "flags" : {},
3432 "signatures" : [
3533 {
3634 "id" : 3 ,
536534 "name" : " ColumnType" ,
537535 "kind" : 32 ,
538536 "kindString" : " Variable" ,
539- "flags" : {},
537+ "flags" : {
538+ "isConst" : true
539+ },
540540 "comment" : {},
541541 "type" : {
542542 "type" : " reflection" ,
591591 "name" : " usedFoo" ,
592592 "kind" : 64 ,
593593 "kindString" : " Function" ,
594- "flags" : {
595- "isConst" : true
596- },
594+ "flags" : {},
597595 "signatures" : [
598596 {
599597 "id" : 8 ,
Original file line number Diff line number Diff line change 10531053 "name" : " Mixin1Func" ,
10541054 "kind" : 64 ,
10551055 "kindString" : " Function" ,
1056- "flags" : {
1057- "isConst" : true
1058- },
1056+ "flags" : {},
10591057 "signatures" : [
10601058 {
10611059 "id" : 20 ,
11581156 "name" : " Mixin2" ,
11591157 "kind" : 64 ,
11601158 "kindString" : " Function" ,
1161- "flags" : {
1162- "isConst" : true
1163- },
1159+ "flags" : {},
11641160 "signatures" : [
11651161 {
11661162 "id" : 34 ,
12731269 "name" : " Mixin3" ,
12741270 "kind" : 64 ,
12751271 "kindString" : " Function" ,
1276- "flags" : {
1277- "isConst" : true
1278- },
1272+ "flags" : {},
12791273 "signatures" : [
12801274 {
12811275 "id" : 52 ,
Original file line number Diff line number Diff line change 8080 "name" : " BigIntLiteralType" ,
8181 "kind" : 32 ,
8282 "kindString" : " Variable" ,
83- "flags" : {},
83+ "flags" : {
84+ "isConst" : true
85+ },
8486 "type" : {
8587 "type" : " literal" ,
8688 "value" : {
9597 "name" : " NegativeBigIntLiteralType" ,
9698 "kind" : 32 ,
9799 "kindString" : " Variable" ,
98- "flags" : {},
100+ "flags" : {
101+ "isConst" : true
102+ },
99103 "type" : {
100104 "type" : " literal" ,
101105 "value" : {
110114 "name" : " negativeOne" ,
111115 "kind" : 32 ,
112116 "kindString" : " Variable" ,
113- "flags" : {},
117+ "flags" : {
118+ "isConst" : true
119+ },
114120 "type" : {
115121 "type" : " literal" ,
116122 "value" : -1
122128 "name" : " numArray" ,
123129 "kind" : 32 ,
124130 "kindString" : " Variable" ,
125- "flags" : {},
131+ "flags" : {
132+ "isConst" : true
133+ },
126134 "type" : {
127135 "type" : " array" ,
128136 "elementType" : {
661669 "name" : " x" ,
662670 "kind" : 32 ,
663671 "kindString" : " Variable" ,
664- "flags" : {},
672+ "flags" : {
673+ "isConst" : true
674+ },
665675 "type" : {
666676 "type" : " literal" ,
667677 "value" : 1
843853 "name" : " leadingRest" ,
844854 "kind" : 32 ,
845855 "kindString" : " Variable" ,
846- "flags" : {},
856+ "flags" : {
857+ "isConst" : true
858+ },
847859 "type" : {
848860 "type" : " tuple" ,
849861 "elements" : [
870882 "name" : " namedTuple" ,
871883 "kind" : 32 ,
872884 "kindString" : " Variable" ,
873- "flags" : {},
885+ "flags" : {
886+ "isConst" : true
887+ },
874888 "type" : {
875889 "type" : " tuple" ,
876890 "elements" : [
901915 "name" : " withOptionalElements" ,
902916 "kind" : 32 ,
903917 "kindString" : " Variable" ,
904- "flags" : {},
918+ "flags" : {
919+ "isConst" : true
920+ },
905921 "type" : {
906922 "type" : " tuple" ,
907923 "elements" : [
932948 "name" : " withRestType" ,
933949 "kind" : 32 ,
934950 "kindString" : " Variable" ,
935- "flags" : {},
951+ "flags" : {
952+ "isConst" : true
953+ },
936954 "type" : {
937955 "type" : " tuple" ,
938956 "elements" : [
959977 "name" : " withRestTypeNames" ,
960978 "kind" : 32 ,
961979 "kindString" : " Variable" ,
962- "flags" : {},
980+ "flags" : {
981+ "isConst" : true
982+ },
963983 "type" : {
964984 "type" : " tuple" ,
965985 "elements" : [
11141134 "name" : " a" ,
11151135 "kind" : 32 ,
11161136 "kindString" : " Variable" ,
1117- "flags" : {},
1137+ "flags" : {
1138+ "isConst" : true
1139+ },
11181140 "type" : {
11191141 "type" : " typeOperator" ,
11201142 "operator" : " unique" ,
You can’t perform that action at this time.
0 commit comments