-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Support declaring @types as the supported route for typings dependencies in the package.json #38249
Comments
I guess I'm not sure what that means since that's already the default assumption if there's no However, this sounds like it's useful for package managers more than anything. I think there's a lot of potential for improving the TypeScript workflow and I've been meaning to follow up with @ethomson about it. Does that sound accurate? Is there something I might've missed? |
If someone is using TS, and installs a It would be much nicer if that could be automated somehow - it perhaps doesn't even need cooperation from package authors :-) |
In yarn 2, the TypeScript plugin's behavior is to automatically grab |
Good to know, but that doesn't help the majority of the ecosystem (npm + yarn v1 + pnpm + etc) :-/ |
As @orta is pointing out above, the issue this might help solve is the version skew. We have seen users opening issues on Express saying the types are out of date or wrong. Well we don't maintain them, so if we publish a new version and they don't, that is not our issue. If on the other hand, we could specify a coordinate of the last known good corresponding types (with a semver range like in the OP), we should be able to reduce this friction. Also, if the TS tooling thinks there is an error, it could point users to DT instead of the express repo, because we just telling them "sorry, not our problem", and that is not a satisfactory UX either. |
So I think discussing through this is good to understand some sort of ideal workflows, but I think there are a couple of issues that aren't getting solved given the current ideas. For example:
I think that a blessed last-known-good version has all the same problems as before (the This is definitely a concern I hold because most JS package authors I've spoken to say that they don't have the resources to maintain
I understand the frustration here, but saying "If this is a mistake, send a pull request to DefinitelyTyped" could be very noisy in our error messages. Maybe there's some room for UX in the editors, but I think you're just better off adding a We've been able to cut out a lot of noise on our repo by doing something similar:
I definitely agree with this, but I don't think TypeScript will get in the business of installing types on its own. Our hope is to continue deferring to existing package managers like we do for automatic type acquisition or Install Missing That said, there's unfortunately a lot of friction around figuring our which |
A separate tool would be perfectly fine. |
@ThisIsMissEm wondered about using |
Search Terms
package json types field types types module
Suggestion
Allow libraries written in JavaScript to be able to declare that they have types in DT (or other modules), and that they support a certain version of it.
For example:
Express does not support TypeScript but trusts that the DefinitelyTyped express maintainers know what they are doing generally. They want to declare that DT is the way for TypeScript users to get types out of the box. Today that's not really possible.
Examples
Two potential routes:
Override the "types" parameter to support:
"types": "@types/express:^3.0"
in a package.jsonRecommend a new field in the package.json:
"typesModule": "@types/express:^3.0"
- then when TypeScript normally offers a 'no types found', then it can offer the command to install with the correct semver range.Checklist
My suggestion meets these guidelines:
/cc @wesleytodd @isaacs @ljharb
The text was updated successfully, but these errors were encountered: