Skip to content
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

no-unused-declaration throws an error with React default props #13

Closed
lukewlms opened this issue Mar 28, 2019 · 1 comment
Closed

no-unused-declaration throws an error with React default props #13

lukewlms opened this issue Mar 28, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@lukewlms
Copy link

lukewlms commented Mar 28, 2019

When I try to run tslint with no-unused-declaration enabled, I get this error:

The 'no-unused-declaration' rule threw an error in '/src/components/Styles.tsx':
TypeError: Cannot read property 'getText' of undefined
at noUnusedDeclarationRule.js:261:25
at Map.forEach ()
at Walker.seen
at Walker.seenJsx
at Walker.visitJsxElement
at Walker.SyntaxWalker.visitNode
at Walker.visitNode
at syntaxWalker.js:535:63
at visitNode
at Object.forEachChild

Here's the component:

export const HeaderButton = (props: IHeaderButtonProps) => {
  return (
    <TouchableOpacity
      {...props}
    >
      <RText
        style={{
          color: props.disabled ? "gray" : "black",
          ...props.textStyle,
        }}
      >
        {props.content}
      </RText>
    </TouchableOpacity>
  );
};

HeaderButton.defaultProps = { disabled: false };

When I remove the defaultProps line, the linter succeeds so it appears that's where the error is. (If I disable no-unused-declaration, linting also succeeds.)

I like the look of the library, but looks like it won't be usable for us unless we can resolve this issue. Thanks for your consideration!

@cartant cartant added the bug Something isn't working label Mar 28, 2019
cartant added a commit that referenced this issue Mar 28, 2019
@cartant
Copy link
Owner

cartant commented Mar 28, 2019

This should be fixed in 1.4.2. Thanks for the helpful bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants