Skip to content

Commit 2c2087d

Browse files
authored
Fix(flow): Allow unnamed parameters (#674)
This allows `type T = number => string`. Previously we were only handling `type T = (x: number) => string` correctly. Followup to #672 that: - Adds a test fixture - Fixes lint errors
1 parent 5bd42d6 commit 2c2087d

File tree

6 files changed

+991
-3
lines changed

6 files changed

+991
-3
lines changed

lib/flow_doctrine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ function flowDoctrine(type/*: Object */)/*: DoctrineType*/ {
100100
params: type.params.map(param => {
101101
let name = '';
102102
if (param.name && param.name.name) {
103-
name = param.name.name;
103+
name = param.name.name;
104104
}
105105
return {
106106
type: 'ParameterType',
107-
name: name,
107+
name,
108108
expression: flowDoctrine(param.typeAnnotation)
109109
};
110110
}),

lib/output/util/format_type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function formatType(getHref/*: Function*/, node/*: ?Object */) {
119119
return [link(node.name, getHref)];
120120
case Syntax.ParameterType:
121121
if (node.name) {
122-
result.push(t(node.name + ': '));
122+
result.push(t(node.name + ': '));
123123
}
124124
return result.concat(formatType(getHref, node.expression));
125125

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @flow
2+
3+
'use strict';
4+
5+
/** x */
6+
let x: T => string;
7+
8+
/** x2 */
9+
let x2: (a: T) => string;
10+
11+
/** T */
12+
type T = string[] => {num: number};
13+
14+
/** T2 */
15+
type T2 = (a: string[]) => {num: number};

0 commit comments

Comments
 (0)
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