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

Add types natively #267

Closed
Himadu2000 opened this issue Jul 29, 2021 · 3 comments
Closed

Add types natively #267

Himadu2000 opened this issue Jul 29, 2021 · 3 comments

Comments

@Himadu2000
Copy link

Could you please add types natively.

For further explanation,
Every time I have to add types/something my package.json file increases. And that's boilerplate code or extra weight.
So could you please add the types with the package.

@lensbart
Copy link

To elaborate on this:

Currently, I’m running into an issue with 2 mismatches versions of @apollo/client in a monorepository.

One @apollo/client is the main dependency, the other one included as a subdependency to @types/apollo-upload-client. Because these types haven’t been updated yet, their dependency requirement lags behind and creates a mismatch, eventually culminating in a runtime error in my app.

Thanks in advance for your consideration! 🙏

@glarivie
Copy link

glarivie commented Aug 4, 2021

same here ✋

@jaydenseric
Copy link
Owner

Thanks for the input everyone, but it's been my carefully considered position for a long time that it's better for everyone if the types are managed independently at Definitely Typed.

  1. It makes this package significantly more maintainable. Apollo related TypeScript types are notorious for churn and bugs.
  2. I'm not the right expert to gate-keep what types are used, and unlike some package authors I'm not willing to rubber-stamp any PR that comes along that touches types since it can have significant consequences for TypeScript users. Definitely Typed are a community of experts with a single purpose; dependable types, with ways to test types, etc.
  3. Externally maintained types allows them to evolve independently of the semver of this package. For example, if I maintained types in this repo, and we decided to publish a better type for part of the API that is a worthwhile breaking change for TypeScript users, I would have to publish a semver major release even though nothing has changed with the actual JavaScript of the API. This would greatly annoy non TypeScript users who see their apollo-upload-client dependency has a major version to update, who then have to investigate the changelog entry to figure out if it's safe to update for their codebase.

I might revisit this policy towards types for my open source projects once Deno (which is overwhelmingly better than Node.js/npm) matures and I've been dogfooding types in my own work. For Deno modules I publish, I plan to use .ts/.tsx for server only modules, and .js/.jsx for modules that could run on both the server and client (with types via JSDoc comments; currently not viable though until denoland/deno#11362 is fixed). Once I'm fully invested in Deno I might leave npm behind though (except for essential maintenance), so in likelihood only my published Deno modules will contain types moving forward.

@lensbart whether it's me maintaining types in this package, or Definitely Typed doing it it in theirs, there is a lag between Apollo publishing changes and other packages updating in response to keep up. Thanks for the implied confidence you have have in me, that I would publish updates faster than Definitely Typed. Maybe I would, maybe I wouldn't - I'm not sure. But regardless, your problem might just be a stale lockfile in your project because @apollo/client is currently v3.4.5, and the @types/apollo-upload-client dependency on it of ^3.1.3 should match it. Try deleting your node_modules and npm or Yarn lockfile, and do a fresh install to freshly dedupe the installed packages.

jaydenseric added a commit that referenced this issue Oct 23, 2023
Past issues about adding TypeScript types:

- #30
- #66
- #215
- #267
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants