-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
no-unused-prop-types is unable to parse type aliases #1446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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: type SomeProps = {
firstname: string
}
type Props = SomeProps;
export class TestComponent extends React.Component<Props, void> {
render() {
return <div>{this.props.foo}</div>
}
} 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). |
This also errors (I think this is related): type TProps = typeof someObject Probably also worth testing @jseminck |
Thanks. Not sure what that syntax means? Is it really valid? Regarding the other case: sorry, have been a bit busy lately. Since it seems that we skip props validation at the moment when we have:
Then I'll probably have to add similar skipping of props validation for:
Several other unexpected cases presented themselves when trying to properly fix it. |
Yes, this is valid Syntax. You can read more about them here: https://flow.org/en/docs/types/typeof/ |
I think this is the same, but at least is another good test case: import AutoComplete from '../rfmui/AutoComplete'
import type {ElementProps} from 'react'
type AutoCompleteProps = ElementProps<typeof AutoComplete> |
Also getting this issue with v7.5.1 Note sure what code is causing this.
|
a workaround for my code was adding type CommonProps = {
bar: string,
}
// TODO: remove `& {}` when eslint-plugin-react/issues/1446 is resolved
type Props = CommonProps & {} |
This looks like it might have been fixed in v7.10.0 (specifically #1806). Should this be closed? |
I'll close; if this is still an issue, please file a new one. |
no-unused-prop-types v.7.4.0 throws when trying to parse this code
The text was updated successfully, but these errors were encountered: