Skip to content

Commit

Permalink
Check for undefined before accessing node.type_annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerlaprade committed Jul 8, 2024
1 parent 51d342b commit 3e02d91
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ module.exports = {
}

function handleFunctionComponent(node) {
const firstArg = node.params[0].typeAnnotation && node.params[0].typeAnnotation.typeAnnotation;
const firstArg = node.params && node.params.length > 0 && node.params[0].typeAnnotation && node.params[0].typeAnnotation.typeAnnotation;
if (firstArg && firstArg.type === 'TSTypeReference') {
const propType = typeAnnotations.get(firstArg.typeName.name)
&& typeAnnotations.get(firstArg.typeName.name)[0];
Expand Down

0 comments on commit 3e02d91

Please sign in to comment.