-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[explicit-module-boundary-types] Warns on constructor overload #2150
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
Comments
Could you please elaborate? Also this code shouldn't ever match the rule, as it should only inspect exported things - could you please provide a full repro? |
I've got this rule warning even without overloading constructor. declare namespace MyClass {
interface Options {
// ...
}
}
declare class MyClass {
constructor(options?: MyClass.Options); // here Missing return type on function @typescript-eslint/explicit-module-boundary-types
}
export = MyClass; Eslint config: const tsPlugin = require('@typescript-eslint/eslint-plugin');
module.exports = {
overrides: [
{
files: ['**/*.ts'],
plugins: ['@typescript-eslint'],
rules: {
...tsPlugin.configs['eslint-recommended'].overrides.rules,
...tsPlugin.configs.recommended.rules,
'no-redeclare': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/require-await': 'off',
},
},
],
}; |
Updates reproduction! |
To me, this warning appears with not only with constructor but also from a function which, both cases, I don't see with v3.0.2. To reproduce, please check out the develop branch of https://github.com/chunghha/docker-ts-nest/tree/develop You will see the warning for former pic below by "yarn lint" with v3.1.0 but won't with v3.0.2 regardless of the eslint-disable-next-line comment there. |
@chunghha - this is expected and intentional. public rate<T>(
@Param('from', new UpperCasePipe()) from: string,
@Param('to', new UpperCasePipe()) to: string,
@Res() response
// ^^^^^^^^ ERROR - THIS PARAMETER IS UNTYPED
): void {
constructor(
@Inject(CONTEXT) private readonly ctx,
// ^^^^^^^^^^^^^^^^^^^^ ERROR - THIS PARAMETER IS UNTYPED
@Inject('winston') private readonly logger: Logger,
private readonly metadataService: MetadataService
) {} In the latest release I reworked the error locations so that they highlight the arguments that are untyped; so your suppression comments are no longer suppressing the errors. |
@bradzacher - the comment is intentional to suppress the warning because I am aware of some of parameters are hard to be typed. And, prettier does formatting of the lines including line breaks. Therefore, I prefer the behavior of v3.0.2 than v3.1.0 if you refer to this location. But, the fix in v3.1.0 is permanent way forward, I'll then adjust the comment location in my code . |
This is intentional and will be the way forward. You should not leave untyped arguments in the codebase. Untyped arguments are simply typed as |
In my issue all the arguments are typed, and it only highlights the overloads. |
It specifically mentions missing the return type. |
Repro
Expected Result
No warnings
Actual Result
Versions
@typescript-eslint/eslint-plugin
3.1.0
@typescript-eslint/parser
3.1.0
TypeScript
3.9.3
ESLint
7.1.0
node
14.2.0
npm
6.14.4
The text was updated successfully, but these errors were encountered: