Skip to content

Commit 23aa981

Browse files
ahutchingstmcw
authored andcommitted
feat: convert Flow's ThisTypeAnnotation to a doctrine NameExpression (#870)
1 parent e73dd98 commit 23aa981

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

__tests__/lib/flow_doctrine.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,15 @@ test('flowDoctrine', function() {
295295
type: 'VoidLiteral'
296296
});
297297

298+
expect(toDoctrineType('this')).toEqual({
299+
type: 'NameExpression',
300+
name: 'this'
301+
});
302+
298303
// TODO: remove all these types
299304
expect(types).toEqual([
300305
'IntersectionTypeAnnotation',
301306
'EmptyTypeAnnotation',
302-
'ThisTypeAnnotation',
303307
'TypeofTypeAnnotation'
304308
]);
305309
});

src/flow_doctrine.js

+5
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ function flowDoctrine(type: Object): DoctrineType {
152152
type: 'StringLiteralType',
153153
value: type.value
154154
};
155+
case 'ThisTypeAnnotation':
156+
return {
157+
type: 'NameExpression',
158+
name: 'this'
159+
};
155160
default:
156161
return {
157162
type: 'AllLiteral'

0 commit comments

Comments
 (0)