diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index f8579bbfcb..11a30d4a43 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -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') { + declaredPropTypes[tsPropertySignature.key.name] = { + fullName: tsPropertySignature.key.name, + name: tsPropertySignature.key.name, + node: tsPropertySignature, + isRequired: !tsPropertySignature.optional + }; + } }); return false; } diff --git a/tests/lib/rules/no-unused-prop-types.js b/tests/lib/rules/no-unused-prop-types.js index 314eaef1d6..d688ce382a 100644 --- a/tests/lib/rules/no-unused-prop-types.js +++ b/tests/lib/rules/no-unused-prop-types.js @@ -5555,6 +5555,23 @@ ruleTester.run('no-unused-prop-types', rule, { } ] }, + { + code: [ + 'interface Foo {', + ' foo: string;', + ' [blah: string]: number;', + '}', + 'const Hello = ({bar}: Foo) => {', + ' return
Hello {bar}
;', + '}' + ].join('\n'), + parser: parsers.TYPESCRIPT_ESLINT, + errors: [ + { + message: '\'foo\' PropType is defined but prop is never used' + } + ] + }, { code: [ 'const Hello = ({firstname}: {firstname: string, lastname: string}) => {',