-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix]
no-unused-prop-types
/TypeScript: avoid crash on indexable int…
…erface Fixes #2687.
- Loading branch information
Showing
2 changed files
with
25 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,12 +314,14 @@ module.exports = function propTypesInstructions(context, components, utils) { | |
} | ||
|
||
foundDeclaredPropertiesList.forEach((tsPropertySignature) => { | ||
declaredPropTypes[tsPropertySignature.key.name] = { | ||
fullName: tsPropertySignature.key.name, | ||
name: tsPropertySignature.key.name, | ||
node: tsPropertySignature, | ||
isRequired: !tsPropertySignature.optional | ||
}; | ||
if (tsPropertySignature.type !== 'TSIndexSignature') { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ljharb
Author
Member
|
||
declaredPropTypes[tsPropertySignature.key.name] = { | ||
fullName: tsPropertySignature.key.name, | ||
name: tsPropertySignature.key.name, | ||
node: tsPropertySignature, | ||
isRequired: !tsPropertySignature.optional | ||
}; | ||
} | ||
}); | ||
return false; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm not 100% sure what's valid in the TS AST here, but one would expect from the
tsPropertySignature
name of the binding that we'd assert that it's actually aTSPropertySignature
instead of anything else.