Skip to content

[consistent-type-assertion] False positive if type is namespaced #629

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

Closed
pietrofxq opened this issue Jun 20, 2019 · 1 comment · Fixed by #975
Closed

[consistent-type-assertion] False positive if type is namespaced #629

pietrofxq opened this issue Jun 20, 2019 · 1 comment · Fixed by #975
Labels
bug Something isn't working good first issue Good for newcomers has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@pietrofxq
Copy link

pietrofxq commented Jun 20, 2019

Repro

{
  "rules": {
        "@typescript-eslint/no-object-literal-type-assertion": "error"
  }
}

I'm trying to make the action parameter in my reducer accept a empty object:

import * as Actions from './actions'
const reducer = (state, action: Actions.ActionType = {} as Actions.ActionType) {}

// removing the namespace throws the error:

import {ActionType} from './actions'
const reducer = (state, action: ActionType = {} as ActionType) {}

adding {"allowAsParameter": true} makes no difference.

Expected Result
There should be no difference in using a namespaced type or not - error should be thrown in both cases

Actual Result
Error is not thrown when type is imported with star

Versions

package version
@typescript-eslint/eslint-plugin 1.10.2
@typescript-eslint/parser 1.10.2
TypeScript 3.5.1
ESLint 5.16
node 10.15.3
@pietrofxq pietrofxq added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jun 20, 2019
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for team members to take a look labels Jun 20, 2019
@bradzacher bradzacher changed the title [no-object-literal-type-assertion] False positive if type is namespaced [consistent-type-assertion] False positive if type is namespaced Jul 27, 2019
@bradzacher bradzacher added the good first issue Good for newcomers label Jul 27, 2019
@bradzacher bradzacher added the has pr there is a PR raised to close this label Sep 17, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 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 has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants