Skip to content

Commit 5bca27e

Browse files
committed
fix: use type args in function comp def rule
1 parent 422ff33 commit 5bca27e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/rules/function-component-definition.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ const UNNAMED_FUNCTION_TEMPLATES = {
3333
};
3434

3535
function hasOneUnconstrainedTypeParam(node) {
36-
if (node.typeParameters) {
37-
return (
38-
node.typeParameters.params.length === 1
39-
&& !node.typeParameters.params[0].constraint
40-
);
36+
const nodeType = node.typeArguments || node.typeParameters;
37+
if (!nodeType) {
38+
return false;
4139
}
4240

43-
return false;
41+
return nodeType.params.length === 1 && !nodeType.params[0].constraint;
4442
}
4543

4644
function hasName(node) {
@@ -207,7 +205,7 @@ module.exports = {
207205
options.range,
208206
buildFunction(options.template, {
209207
typeAnnotation,
210-
typeParams: getNodeText(node.typeParameters, source),
208+
typeParams: getNodeText(node.typeArguments || node.typeParameters, source),
211209
params: getParams(node, source),
212210
returnType: getNodeText(node.returnType, source),
213211
body: getBody(node, source),

0 commit comments

Comments
 (0)