-
Notifications
You must be signed in to change notification settings - Fork 889
no-unsafe-any: should not complain about function calls which parameters are using any #2728
Comments
Could you provide a reproducible example? |
Here is a repro repo https://github.com/CSchulz/tslint-no-unsafe-any-showcase I am not sure about the imports in test.ts which is also violated with unsafe any, but the usage of methods in the app.component.spec.ts should be okay.
|
I cloned your repo and and tried to reproduce the lint failures. Ignoring
These are expected failures. Maybe there is something missing in your repro repo? |
I have the feeling that there are some incompatibilities between different extensions for tslint. I have tested it again in this moment and I got the same violations as @ajafff. I will try to upload a shrinkwrap file to show my depdency tree. |
Seems to be a collision with no-unused-variable. You should reproduce it with the following rules:
|
May be #2649. |
Yes could be possible, I was not sure. I am still wondering how I got this error with the initial ruleset. |
I can avoid the issue with the initial ruleset after reinstalling the dependencies from scratch. I can't tell which dependencies make trouble with each other. |
The usage of |
|
So every type which is finally any leads to this violation? |
Not sure what you mean -- only |
I meant everytime any is used somewhere in the declaration like in this case How can you prevent it? Using some type assertion using with the |
You could always help improve the typings and get rid of |
Would it be possible to define something better f.e. for the Injectable |
@CSchulz I use this in a .d.ts file if it can help: import core from '@angular/core';
declare module '@angular/core' {
export interface InjectableDecorator {
(): ClassDecorator;
}
export const Injectable: InjectableDecorator;
export interface HostBindingDecorator {
(hostPropertyName?: string): PropertyDecorator;
}
export const HostBinding: HostBindingDecorator;
export interface HostListenerDecorator {
(eventName: string, args?: string[]): MethodDecorator;
}
export const HostListener: HostListenerDecorator;
} |
@nicolashenry Thanks, did you consider to contribute it to angular itself? |
@CSchulz I will but it will take some time. |
Thanks, do you have some typings also for the provider definitions? |
Do I have to name the file special or do I need a different configuration for tslint? I have tried to configure the folder as types root in the tsconfig.json without any change. I am using the normal Angular CLI environment. |
I'm also getting extraneous errors when using this rule in combination with no-unused-variables. If I disable that rule, the errors for no-unsafe-any go. I'm also seeing extraneous errors with no-inferred-object when used in combination with no-unused-variables |
Has anyone found a solution for this? I tried the edited I tried @nicolashenry 's workaround again and looked at the errors it created, and it turned out that it unearthed a whole bunch of cases where a sclerotic |
Going to close this in favor of #2649, as that seems to be the root of these weird side-effectful issues around no-unused-variable. |
🤖 Beep boop! 👉 TSLint is deprecated 👈 and you should switch to typescript-eslint! 🤖 🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋 |
Bug Report
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
Unsafe use of expression of type 'any'.
Expected behavior
Should not complain about the function
inject
call.The text was updated successfully, but these errors were encountered: