-
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
Add "allowImplicitAnyImports" compiler option for usage with "noImplicitAny" #15878
Comments
#6615 should help. |
More docs available at http://www.typescriptlang.org/docs/handbook/modules.html#shorthand-ambient-modules |
Thanks. From those resources, the recommendation seems to be "Add one file to your project that contains a This is not ideal, but it works. I'd rather not have the extra file, and I'd especially rather not have to add a line to that file for each Still, it would be much better to have the compiler option. But if it's already been reviewed and decided against by the team, that's fair. |
There's also |
Thanks, I missed that. I thought it was going to make all modules However, with What's the rationale against this compiler option? That this issue was tagged "Question" instead of "Suggestion" when I was aiming for the latter implies one exists, I think. From the discussions I've read in the issues, and from the current lack of a usage pattern that is both non-invasive and exactly equivalent, it seems like the rationale is that its benefit to the user doesn't outweigh the cost to develop it. But if that were true, this should be tagged "Suggestion" instead of "Question", since I'm assuming one measure of user benefit is how many users indicate they would benefit from it. Would something in TS break or become inconsistent if this compiler option existed? |
Could someone please remove the Question label and add the Suggestion label? I'm asking because this issue was drafted as a suggestion, not as a question, and the suggested functionality is not fully provided by the (still very helpful) workarounds given by the team here and in other issues' discussions. For other TS users out there who (a) have encountered this same deficiency in TS, (b) want this compiler option, and (c) are browsing and searching the issues, the labeling should indicate that this issue is a valid suggestion --- unless it isn't, but that hasn't been explained (or even asserted). Thanks. |
Marking as suggestion. but i do not think we will be doing this any time soon. The compiler has a default behavior of treating all imports with no associated declaration files as Allowing the The language also has affordances for declaring modules, so you can declare specific modules that you do not have declaration files for as |
@mhegazy Thanks for replying (and re-labeling).
This isn't in doubt at all. I'm with you 100% on this. However, when you use an externally packaged module that is simply not actually (or correctly) typed, you have no choice but to deal with The good news is that we have The bad news is
I feel like we're talking past each other and that this really comes down to a disagreement over whether "bad news 2" is actually bothersome. |
this seems like one or
what i am arguing here is that you are not using the benefits of
and this is the intention. the idea is you made a conscious decision to treat some modules as any, and you are aware of the implications. |
I think I'll have to defer to your experience on this one, because I can only offer the single data point of my own project as counter-evidence. My colleagues and I have definitely benefited from I agree that the workarounds are appropriate and not usually a big bother. From my own viewpoint though, they leave a small gap where there's actually a valuable user story. I have to admit I can't argue that the value is non-negligible at this point, though. Thank you both for the help and insight. |
I think that's too strong of a statement, the flag is just about preventing implicit What seems strange to me is that variables and consts can be marked with For reference, For me, it comes down to usability: in the world of various npm modules, untyped imports are quite common and it's currently not intuitive how to deal with it easily. I've seen people just doing |
TypeScript Version: 2.3.2
Code
Desired behavior:
The compiler emits no error.
Actual behavior:
The compiler emits this error:
Motivation:
noImplicitAny
turned on for my own code.@types
packages, which for many JS packages do not exist. (And unfortunately some of the ones that do exist are poorly maintained.).d.ts
files for every non-typed third-party JS package I need to use.The text was updated successfully, but these errors were encountered: