-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Move type dependencies as dev deps #1062
Conversation
Attempt to fix #1061
Seems to be also related to: #1041 |
Hm, I feel like we're going in circles with Typescript here... #733 #949. Is there really no way in Typescript to have projects just work and download the correct typings when they're installed, but also work in plain JavaScript without requiring the typings? And is it really the case that if you use typings for graphql and other things, none of your dependencies can use different typings for those packages without getting you into a world of pain? Is it just me or is this a huge drawback of using Typescript? Anyway, trying to be a bit more productive: if we merge this PR, will people get warnings about missing typings and be required to install them by hand? Are we really fixing anything here, or are we just choosing the less bad of two possible solutions? |
I'm totally on board with your frustration, Jonas. This is super painful and definitely a big issue when using Typescript currently. We're having similar problems for @rricard strongly encouraged us to consider switching over to flow. What's your stand on this @helfer? |
@schickling again, no, you seem to already master the TS compilation chain already, mastering flow will be painful for you. We need to clearly define what to expect from our package and whatnot. So my take on this would be to import less and document... Or eventually, only add to optionalDeps the things required by the typedef file. I clearly don't know at this point, @schickling can you try removing all of your custom definitions? As stated before, it works on an isolated example: https://github.com/apollostack/typed-graphql-client-example/tree/react. Maybe if you can find a minimal example breaking things as we talked yesterday... Apart from that, I'm currently in the mountains with a weak internet connection so I doubt I can help you very much this week... I agree though we shouldn't merge that yet... |
I think the issue as @helfer said is overlapping type definitions (possibly the graphql definitions). Any ideas on how to ignore/workaround that? |
Use |
Thanks for your comment @basarat. Do you have any idea how to tackle this problem more at its core? |
to help me figure out, can you point out how flowtype would be different technically in handling the situation 🌹 |
@basarat Flow is still beginning in the "how to handle a library" field. For now, you pretty much control everything, which is good but requires more setup. What you do is point to directories containing typedefs in the config file. To makes things a bit easy though, the provide a DefinitelyTyped-like called flow-typed (much smaller though...). But one thing flow doesn't have to handle, since typing is optional per file (with the Typescript on the other hand wants you to explicitly type everything, which can be good but will prevent you from compiling in some situations like this one. So I think there is no clear answer to that yet, if TS had a precedence system letting you choose which typedef (from node_modules, or from my typings file?) to use, that would help maybe... But the truth is, sometimes things clash and unfortunately, this affects libs like this one that try to be a good TS citizen but will expose too few or too much and ruin the developer experience at the same time. |
@basarat, So my main question is more meta maybe: How to be a good library exposing its TS typedefs? That's what Apollo tries to be and I admit I don't have the experience to do figure that out correctly by myself. But I think there can be a set of rules/conventions, TS libraries could apply to be good TS-ready libraries, defining them in a manifesto or even just a blogpost could be useful to us and I would be really grateful if someone did that. Because even if I'm just toying with TS, knowing how to expose correctly my typedefs could be beneficial when writing libraries... |
TypeScript supports the same in nightly now : microsoft/TypeScript#12358 anything that is in
If the project is in typescript it should just use
If your project depends on external global things like Hope this helps ❤️ |
In general the advice we've given to people is to put their declaration files into
One potential option is to list your declarations as Finally, you can also just publish your declarations to DefinitelyTyped and thus Note: One thing that we'll be doing down the road in DefinitelyTyped is to have "redirects" (which is probably just going to be a submodule within DefinitelyTyped). You might be able to take advantage of that down the road. While I understand that there is a little bit of hesitance to have
Requiring an out-of-band package manager is one of the most exhausting, frustrating, confusing, and time-consuming things you can do for new TypeScript users. Our community has gone through two package managers, and the overhead for new users is surprisingly staggering. What we've found is that overlaying TypeScript on top of existing/familiar concepts in the JavaScript world has been the most user-friendly option. |
Thanks a lot for all these constructive and insightful comments. I think I've pinged @blakeembrey about this and got some helpful pointers how to resolve the underlying problem here:
So if I'm not mistaken then #1041 might be able to resolve this? (/cc @stubailo) |
@basarat & @DanielRosenwasser thank you for this information. I'll let @stubailo & @helfer tell me what they prefer in the solutions you gave me and I'll get to work. But I think, seeing what's happening here that sending the typedefs to DefinitelyTyped may be the best option, I would just wait though for now to see if |
Thanks for the advice @DanielRosenwasser! @rricard let's first make sure we use @schickling do you have a simple setup that could help us test whether we've solved the problems for typescript developers as we implement these changes? |
The |
@rricard @schickling most of this should be implemented with this commit. Once I release 0.7 (in a day or two) we can test it! |
Attempt to fix #1061
TODO: