This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
test/fixtures/convert/interfaces/interface-well-known-symbol01 Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -138,8 +138,8 @@ export const ObjectTypeCallProperty = {
138
138
139
139
export const ObjectTypeProperty = {
140
140
exit ( path , state ) {
141
+ let { key } = path . node ;
141
142
const {
142
- key,
143
143
value,
144
144
optional,
145
145
variance,
@@ -151,9 +151,8 @@ export const ObjectTypeProperty = {
151
151
} = path . node ; // TODO: static, kind
152
152
const typeAnnotation = t . tsTypeAnnotation ( value ) ;
153
153
const initializer = undefined ; // TODO: figure out when this used
154
- const computed = false ; // TODO: maybe set this to true for indexers
154
+ let computed = false ;
155
155
const readonly = variance && variance . kind === "plus" ;
156
-
157
156
if ( variance && variance . kind === "minus" ) {
158
157
// TODO: include file and location of infraction
159
158
console . warn ( "typescript doesn't support writeonly properties" ) ;
@@ -162,6 +161,16 @@ export const ObjectTypeProperty = {
162
161
console . warn ( "we don't handle get() or set() yet, :P" ) ;
163
162
}
164
163
164
+ if ( t . isIdentifier ( key ) ) {
165
+ if ( key . name . startsWith ( "@@" ) ) {
166
+ key = t . memberExpression (
167
+ t . identifier ( "Symbol" ) ,
168
+ t . identifier ( key . name . replace ( "@@" , "" ) )
169
+ ) ;
170
+ computed = true ;
171
+ }
172
+ }
173
+
165
174
if ( method ) {
166
175
// TODO: assert value is a FunctionTypeAnnotation
167
176
const methodSignature = {
Original file line number Diff line number Diff line change
1
+ interface Iterable < T > {
2
+ @@iterator ( ) : Iterator < T > ;
3
+ }
Original file line number Diff line number Diff line change
1
+ interface Iterable < T > {
2
+ [ Symbol . iterator ] ( ) : Iterator < T > ;
3
+ }
You can’t perform that action at this time.
0 commit comments