File tree Expand file tree Collapse file tree 2 files changed +87
-27
lines changed Expand file tree Collapse file tree 2 files changed +87
-27
lines changed Original file line number Diff line number Diff line change @@ -1087,7 +1087,6 @@ Template literal types
1087
1087
type A<B, C> = `${B}${C}`;
1088
1088
type A = `${B[0]}-foo-${C}-bar-${D<U, D>}`
1089
1089
type A = `[${'a'}${0}]`
1090
-
1091
1090
type A<B, C> = B extends C
1092
1091
? C extends string
1093
1092
? `${C}${"" extends C ? "" : "."}${B}`
@@ -1134,32 +1133,92 @@ type A<B, C> = B extends C
1134
1133
(template_type
1135
1134
(literal_type
1136
1135
(number)))))
1137
- (type_alias_declaration
1138
- (type_identifier)
1139
- (type_parameters
1140
- (type_parameter
1141
- (type_identifier))
1142
- (type_parameter
1143
- (type_identifier)))
1136
+ (type_alias_declaration
1137
+ (type_identifier)
1138
+ (type_parameters
1139
+ (type_parameter
1140
+ (type_identifier))
1141
+ (type_parameter
1142
+ (type_identifier)))
1143
+ (conditional_type
1144
+ (type_identifier)
1145
+ (type_identifier)
1146
+ (conditional_type
1147
+ (type_identifier)
1148
+ (predefined_type)
1149
+ (template_literal_type
1150
+ (template_type
1151
+ (type_identifier))
1152
+ (template_type
1144
1153
(conditional_type
1154
+ (literal_type
1155
+ (string))
1145
1156
(type_identifier)
1146
- (type_identifier)
1147
- (conditional_type
1157
+ (literal_type
1158
+ (string))
1159
+ (literal_type
1160
+ (string))))
1161
+ (template_type
1162
+ (type_identifier)))
1163
+ (type_identifier))
1164
+ (type_identifier))))
1165
+
1166
+ ==================================
1167
+ Mapped type 'as' clauses
1168
+ ==================================
1169
+
1170
+ type A<B> = { [B in keyof C & string as `get${Capitalize<P>}`]: () => A[B] };
1171
+ type A<B> = { [B in keyof C & string as `${P}1` | `${P}2`]: A[B] }
1172
+
1173
+ ---
1174
+
1175
+ (program
1176
+ (type_alias_declaration
1177
+ (type_identifier)
1178
+ (type_parameters
1179
+ (type_parameter
1180
+ (type_identifier)))
1181
+ (object_type
1182
+ (index_signature
1183
+ (mapped_type_clause
1184
+ (type_identifier)
1185
+ (intersection_type
1186
+ (index_type_query
1187
+ (type_identifier))
1188
+ (predefined_type))
1189
+ (template_literal_type
1190
+ (template_type
1191
+ (generic_type
1148
1192
(type_identifier)
1149
- (predefined_type)
1150
- (template_literal_type
1151
- (template_type
1152
- (type_identifier))
1153
- (template_type
1154
- (conditional_type
1155
- (literal_type
1156
- (string))
1157
- (type_identifier)
1158
- (literal_type
1159
- (string))
1160
- (literal_type
1161
- (string))))
1162
- (template_type
1163
- (type_identifier)))
1164
- (type_identifier))
1165
- (type_identifier))))
1193
+ (type_arguments
1194
+ (type_identifier))))))
1195
+ (type_annotation
1196
+ (function_type
1197
+ (formal_parameters)
1198
+ (lookup_type
1199
+ (type_identifier)
1200
+ (type_identifier)))))))
1201
+ (type_alias_declaration
1202
+ (type_identifier)
1203
+ (type_parameters
1204
+ (type_parameter
1205
+ (type_identifier)))
1206
+ (object_type
1207
+ (index_signature
1208
+ (mapped_type_clause
1209
+ (type_identifier)
1210
+ (intersection_type
1211
+ (index_type_query
1212
+ (type_identifier))
1213
+ (predefined_type))
1214
+ (union_type
1215
+ (template_literal_type
1216
+ (template_type
1217
+ (type_identifier)))
1218
+ (template_literal_type
1219
+ (template_type
1220
+ (type_identifier)))))
1221
+ (type_annotation
1222
+ (lookup_type
1223
+ (type_identifier)
1224
+ (type_identifier)))))))
Original file line number Diff line number Diff line change @@ -667,6 +667,7 @@ module.exports = function defineGrammar(dialect) {
667
667
$ . _type_identifier ,
668
668
'in' ,
669
669
$ . _type ,
670
+ optional ( seq ( 'as' , $ . _type ) )
670
671
) ,
671
672
672
673
literal_type : $ => choice (
You can’t perform that action at this time.
0 commit comments