File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -819,6 +819,7 @@ module.exports = function defineGrammar(dialect) {
819
819
_type_query_member_expression : $ => seq (
820
820
field ( 'object' , choice (
821
821
$ . identifier ,
822
+ $ . this ,
822
823
alias ( $ . _type_query_subscript_expression , $ . subscript_expression ) ,
823
824
alias ( $ . _type_query_member_expression , $ . member_expression ) ,
824
825
alias ( $ . _type_query_call_expression , $ . call_expression ) ,
@@ -832,6 +833,7 @@ module.exports = function defineGrammar(dialect) {
832
833
_type_query_subscript_expression : $ => seq (
833
834
field ( 'object' , choice (
834
835
$ . identifier ,
836
+ $ . this ,
835
837
alias ( $ . _type_query_subscript_expression , $ . subscript_expression ) ,
836
838
alias ( $ . _type_query_member_expression , $ . member_expression ) ,
837
839
alias ( $ . _type_query_call_expression , $ . call_expression ) ,
@@ -865,6 +867,7 @@ module.exports = function defineGrammar(dialect) {
865
867
alias ( $ . _type_query_call_expression , $ . call_expression ) ,
866
868
alias ( $ . _type_query_instantiation_expression , $ . instantiation_expression ) ,
867
869
$ . identifier ,
870
+ $ . this ,
868
871
) ,
869
872
) ) ,
870
873
Original file line number Diff line number Diff line change @@ -2100,7 +2100,7 @@ type X2 = (typeof Y)[keyof typeof Z];
2100
2100
(identifier))))))
2101
2101
2102
2102
=========================
2103
- Type of instantiation expressions
2103
+ Typeof instantiation expressions
2104
2104
=========================
2105
2105
2106
2106
// This is a special construct, different from both "typeof (f<T>)" and
@@ -2119,3 +2119,51 @@ type T = typeof f<T>;
2119
2119
(identifier)
2120
2120
(type_arguments
2121
2121
(type_identifier))))))
2122
+
2123
+ =========================
2124
+ Typeof this
2125
+ =========================
2126
+
2127
+ class A {
2128
+ colors: [ { color: "green", code: "#E5F8F2" } ]
2129
+ color: (typeof this.colors)[number] = this.colors[0]
2130
+ }
2131
+
2132
+ ---
2133
+
2134
+ (program
2135
+ (class_declaration
2136
+ (type_identifier)
2137
+ (class_body
2138
+ (public_field_definition
2139
+ (property_identifier)
2140
+ (type_annotation
2141
+ (tuple_type
2142
+ (object_type
2143
+ (property_signature
2144
+ (property_identifier)
2145
+ (type_annotation
2146
+ (literal_type
2147
+ (string
2148
+ (string_fragment)))))
2149
+ (property_signature
2150
+ (property_identifier)
2151
+ (type_annotation
2152
+ (literal_type
2153
+ (string
2154
+ (string_fragment)))))))))
2155
+ (public_field_definition
2156
+ (property_identifier)
2157
+ (type_annotation
2158
+ (lookup_type
2159
+ (parenthesized_type
2160
+ (type_query
2161
+ (member_expression
2162
+ (this)
2163
+ (property_identifier))))
2164
+ (predefined_type)))
2165
+ (subscript_expression
2166
+ (member_expression
2167
+ (this)
2168
+ (property_identifier))
2169
+ (number))))))
You can’t perform that action at this time.
0 commit comments