diff --git a/lib/flow_doctrine.js b/lib/flow_doctrine.js index a7e46c07b..49a28d83e 100644 --- a/lib/flow_doctrine.js +++ b/lib/flow_doctrine.js @@ -98,9 +98,13 @@ function flowDoctrine(type/*: Object */)/*: DoctrineType*/ { return { type: 'FunctionType', params: type.params.map(param => { + let name = ''; + if (param.name && param.name.name) { + name = param.name.name; + } return { type: 'ParameterType', - name: param.name.name, + name: name, expression: flowDoctrine(param.typeAnnotation) }; }), diff --git a/lib/output/util/format_type.js b/lib/output/util/format_type.js index 19ed6913d..242954623 100644 --- a/lib/output/util/format_type.js +++ b/lib/output/util/format_type.js @@ -118,7 +118,10 @@ function formatType(getHref/*: Function*/, node/*: ?Object */) { case Syntax.NameExpression: return [link(node.name, getHref)]; case Syntax.ParameterType: - return [t(node.name + ': ')].concat(formatType(getHref, node.expression)); + if (node.name) { + result.push(t(node.name + ': ')); + } + return result.concat(formatType(getHref, node.expression)); case Syntax.TypeApplication: return formatType(getHref, node.expression) diff --git a/test/lib/flow_doctrine.js b/test/lib/flow_doctrine.js index 1ba50537e..df0505fd2 100644 --- a/test/lib/flow_doctrine.js +++ b/test/lib/flow_doctrine.js @@ -181,6 +181,19 @@ test('flowDoctrine', function (t) { name: 'boolean' }, 'boolean'); + t.deepEqual(toDoctrineType('any => any'), + { + type: 'FunctionType', + params: [ + { + expression: {type: 'AllLiteral'}, + name: '', + type: 'ParameterType' + } + ], + result: {type: 'AllLiteral'}, + }, ''); + t.deepEqual(toDoctrineType('undefined'), { type: 'NameExpression', pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy