Skip to content

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

Closed
@pietrofxq

Description

@pietrofxq

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershas prthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions