Skip to content

Commit

Permalink
fix(eslint-plugin): no-object-literal-type-assertion: fix as const
Browse files Browse the repository at this point in the history
…is reported
  • Loading branch information
rhysd committed Mar 30, 2019
1 parent f29d1c9 commit e4a02c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Expand Up @@ -50,6 +50,9 @@ export default util.createRule<Options, MessageIds>({
case AST_NODE_TYPES.TSAnyKeyword:
case AST_NODE_TYPES.TSUnknownKeyword:
return false;
case AST_NODE_TYPES.Identifier:
// Ignore `as const` and `<const>` (#166)
return node.name !== 'const';
default:
return true;
}
Expand Down
Expand Up @@ -26,6 +26,8 @@ ruleTester.run('no-object-literal-type-assertion', rule, {
// Allow cast to 'unknown'
`const foo = {} as unknown;`,
`const foo = <unknown> {};`,
`const foo = {} as const;`,
`const foo = <const> {};`,
{
code: `print({ bar: 5 } as Foo)`,
options: [
Expand Down

0 comments on commit e4a02c3

Please sign in to comment.