Skip to content

[no-object-literal-type-assertion] make allowAsParameter work with "throw" keyword? #668

@ZYinMD

Description

@ZYinMD
{
  "rules": {
    "@typescript-eslint/no-object-literal-type-assertion": ["error", {
      "allowAsParameter": true 
    }]
  }
}

My code:

else throw { code: 'E42', message: 'foo failed' } as CustomError;

Expected Result
I hope eslint would allow it, since I've set "allowAsParameter": true

Actual Result
It's not allowed, because throw is not a function, it's a function-like keyword, just like typeof or delete.

Could we make it treat throw as a function in regards to "allowAsParameter": true ?

Versions

package version
@typescript-eslint/eslint-plugin 1.9.0
@typescript-eslint/parser 1.9.0
TypeScript 3.4.5
ESLint 5.16.0
node 10.15.3
npm 6.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement: plugin rule optionNew rule option for an existing eslint-plugin rulehas 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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy