Skip to content

import/named error for JSDoc typedef #1381

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

Closed
matt-tingen opened this issue Jun 12, 2019 · 3 comments
Closed

import/named error for JSDoc typedef #1381

matt-tingen opened this issue Jun 12, 2019 · 3 comments

Comments

@matt-tingen
Copy link

In TypeScript with the allowJs flag, types defined in a JSDoc can be imported in .ts files, but the import/named rule is not aware of the implicit export from the JSDoc and thus marks the import as invalid.

Example:

// Foo.js
/** @typedef {keyof Foo} FooKey */
class Foo { /* ... */ }
export default Foo;
// Bar.ts
import Foo, { FooKey } from './Foo';

This yields error FooKey not found in './Foo' import/named.

It may be possible to use tsdoc to extract the type definitions.

Related: #1282

@ljharb
Copy link
Member

ljharb commented Jun 12, 2019

oof, this seems very complex. i'd want to enable this by a setting only, not by default.

@matt-tingen
Copy link
Author

Absolutely. Honestly, I'm not totally sure how worth it it would be to implement. Personally, I just disabled import/named for .tsx? files in our project since TS performs the check, anyway.

@JounQin
Copy link
Collaborator

JounQin commented Jul 19, 2022

You can use

import Foo, { type FooKey } from './Foo';

It won't error now.

@JounQin JounQin closed this as completed Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants