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

Possible false positive import/namespace error on exported type #3019

Open
corydeppen opened this issue Jun 22, 2024 · 5 comments
Open

Possible false positive import/namespace error on exported type #3019

corydeppen opened this issue Jun 22, 2024 · 5 comments

Comments

@corydeppen
Copy link

I'm seeing the following ESLint error when trying to use a namespace import for React Aria Components. I'm unsure whether this could be related to the config in the default .eslintrc.cjs file of the Remix template or if it might be a false positive being reported. ButtonProps is being exported by the RAC module, so it's confusing why this error would be shown.

'ButtonProps' not found in imported namespace 'ReactAria'. eslint(import/namespace)
import * as ReactAria from "react-aria-components";

// ...

export interface ButtonProps
  extends ReactAria.ButtonProps,
    VariantProps<typeof buttonVariants> {}

// ...

The error is not reported when I use the namespace import for exports that aren't types:

<ReactAria.Button {...props} />

Running npm run lint in the example app will show the error mentioned above.

Any ideas what might be happening here and whether this is expected or not?

@ljharb
Copy link
Member

ljharb commented Jun 23, 2024

If the import works, I'd expect the plugin to recognize it. What happens if you do import { ButtonProps } from 'react-aria-components'?

@corydeppen
Copy link
Author

There's no error when aliases are used.

import {
  Button as RacButton,
  ButtonProps as RacButtonProps,
} from 'react-aria-components';

@ljharb
Copy link
Member

ljharb commented Jun 23, 2024

With no aliases, but also with no *?

@corydeppen
Copy link
Author

No lint errors without aliases or * - I've updated the example.

@corydeppen
Copy link
Author

I'm not sure whether it helps narrow down the issue or not, but I noticed the lint error only seems to be thrown when the namespace import is used to extend a type but not when it's used as an annotation. This can be seen in the label module I just added to the example app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants