-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Missing type declarations #3776
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
It's simply not a reasonable expectation that an npm package ships TS types, nor necessarily has a DT package. "Write everything in TS" isn't a universally palatable choice. At some point in the future, we may ship d.ts files, but in the meantime, the proper solution (for every npm package that doesn't ship types) is to make a DT package. |
Not an expectation, but certainly good to have. The effort required to write a type declaration file for a package like this is fairly low too, so I don't think it is unreasonable to suggest it. I even offered to submit a PR myself. Hmm, a DT package does not seem preferable. The DT repo is pretty bloated, it requires devs to install yet another package, the effort required to make it is higher, and it's easier to keep types in sync when they are alongside the code. Excluding massive packages like You mentioned the possibility of "at some point in the future". But does closing this issue as "not planned" mean you are completely opposed to the idea? If not, I would be happy to add them now - a single |
I’m not opposed to the idea, but i don’t think now is a good time to make such a PR. It’d also need to include jsdoc comments and tsc checking in CI, as well, so it’s not as simple as writing up a d.ts file. |
Is there an existing issue for this?
Description Overview
When imported in a TypeScript environment,
eslint-plugin-react
throws a "missing type declarations" error.Why
This is because
eslint-plugin-react
does not have any type declarations included in the package. These would usually be in anindex.d.ts
file.Expected Behavior
The expected behavior is no errors. Type declarations would also be convenient for intellisense and type hints - like easily communicating to users what the available config types are, for example.
Workaround
Users can follow the instructions in the error message and make a temporary module augmentation to declare their own types for the package.
In my personal project, I've done it this way:
Solution
Personally, I'd always recommended writing everything in TypeScript, and then type declaration files will be automatically generated for you :)
But the quick and easy solution would be to write your own
index.d.ts
declaration file in the project root.I would be happy submit a PR for this myself, if it helps.
eslint-plugin-react version
v7.34.3 (but technically all versions)
eslint version
v8.57.0 (irrelevant)
node version
v20.13.1 (irrelevant)
The text was updated successfully, but these errors were encountered: