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

[no-type-alias] False positive with constructor aliases #1191

Closed
mdouglass opened this issue Nov 11, 2019 · 2 comments · Fixed by #1198
Closed

[no-type-alias] False positive with constructor aliases #1191

mdouglass opened this issue Nov 11, 2019 · 2 comments · Fixed by #1198
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@mdouglass
Copy link

Repro

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": { "project": "./tsconfig.json", "sourceType": "module" },
  "plugins": ["@typescript-eslint"],
  "rules": {
    "@typescript-eslint/no-type-alias": ["error", { "allowCallbacks": "always" }]
  }
}
type ConstructorFunction = new (port: string) => any

Expected Result
No warning because allowCallbacks is set to always

Actual Result
1:26 error Type unhandled are not allowed @typescript-eslint/no-type-alias

Additional Info
If the new is removed then this code passes without errors, so I presume it is because constructors are not handled. It is possible that this should be a new option (allowConstructors) rather than rolled into allowCallbacks.

Versions

package version
@typescript-eslint/eslint-plugin 2.6.1
@typescript-eslint/parser 2.6.1
TypeScript 3.7.2
ESLint 6.6.0
node 13.1.0
npm 6.12.1
@mdouglass mdouglass added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Nov 11, 2019
@bradzacher bradzacher added bug Something isn't working good first issue Good for newcomers and removed triage Waiting for maintainers to take a look labels Nov 11, 2019
@a-tarasyuk
Copy link
Contributor

@bradzacher Is it a bug? Or need to add the new option allowConstructors?

@bradzacher
Copy link
Member

It's a bit of both.

It's a case that was never thought of, hence it's marked as "unhandled"

// unhandled type - shouldn't happen
reportError(type.node, type.compositionType, isTopLevel, 'Unhandled');

But it also doesn't really fit into any of the existing options. The closest would probably be allowCallbacks, but it's still not quite right.

So it's a bug that needs to be handled with a new option.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants