no-unused-prop-types is unable to parse type aliases
See original GitHub issueno-unused-prop-types v.7.4.0 throws when trying to parse this code
type SomeProps = {};
type DefaultProps = SomeProps;
type Props = DefaultProps & {};
export class TestComponent extends React.Component<Props, void> {}
TypeError: Cannot read property 'length' of undefined
at iterateProperties (eslint-plugin-react/lib/rules/no-unused-prop-types.js:336:21)
at declarePropTypesForObjectTypeAnnotation (eslint-plugin-react/lib/rules/no-unused-prop-types.js:725:7)
at propTypes.types.some.annotation (eslint-plugin-react/lib/rules/no-unused-prop-types.js:767:16)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Relax visibility rules for type-aliases when 'declaration ...
When using the declaration compiler option, this example fails to compile with the following error: error TS4078: Parameter 'fn' of exported ...
Read more >Types: Type Aliases - HHVM and Hack Documentation
A type alias can be created in two ways: using type and newtype . ... meaning the including file cannot perform any integer-like...
Read more >'type aliases' can only be used in a .ts file. TS8008 - Stack ...
Failed to compile. Type error: 'type aliases' can only be used in a .ts file. TS8008. That's because I have the following code...
Read more >Documentation - TypeScript 4.2
TypeScript has a way to declare new names for types called type aliases. If you're writing a set of functions that all work...
Read more >TypeScript | Type Aliases - Codecademy
In TypeScript, type aliases create type definitions, using the `type` keyword and a name, that can be reused throughout the code.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, this is valid Syntax. You can read more about them here: https://flow.org/en/docs/types/typeof/
Thanks for the report.
I did some quick digging and reproduced the issue. Additionally I found that the following code did parse correctly, but did not detect unused prop-types:
I have managed to get both cases working (your example + the above). I’ll try to get a PR in within the next few days (as I’m currently travelling a bit).