From 32335bb84dbb089b54f8a73793725d1128ef1aff Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Wed, 9 Aug 2017 11:21:22 -0400 Subject: [PATCH] =?UTF-8?q?Add=20support=20for=20converting=20flow?= =?UTF-8?q?=E2=80=99s=20ThisTypeAnnotation=20to=20a=20doctrine=20NameExpre?= =?UTF-8?q?ssion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/lib/flow_doctrine.js | 6 +++++- src/flow_doctrine.js | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/__tests__/lib/flow_doctrine.js b/__tests__/lib/flow_doctrine.js index 00365694c..871acbd31 100644 --- a/__tests__/lib/flow_doctrine.js +++ b/__tests__/lib/flow_doctrine.js @@ -295,11 +295,15 @@ test('flowDoctrine', function() { type: 'VoidLiteral' }); + expect(toDoctrineType('this')).toEqual({ + type: 'NameExpression', + name: 'this' + }); + // TODO: remove all these types expect(types).toEqual([ 'IntersectionTypeAnnotation', 'EmptyTypeAnnotation', - 'ThisTypeAnnotation', 'TypeofTypeAnnotation' ]); }); diff --git a/src/flow_doctrine.js b/src/flow_doctrine.js index 031c4124e..25f18f756 100644 --- a/src/flow_doctrine.js +++ b/src/flow_doctrine.js @@ -152,6 +152,11 @@ function flowDoctrine(type: Object): DoctrineType { type: 'StringLiteralType', value: type.value }; + case 'ThisTypeAnnotation': + return { + type: 'NameExpression', + name: 'this' + }; default: return { type: 'AllLiteral'