Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[no-object-literal-type-assertion] False positive when asserting function argument #66

Closed
Assignees
armano2
Labels
@IlyaSemenov

Description

@IlyaSemenov

Repro

module.exports={root:true,plugins:["typescript"],parser:"typescript-eslint-parser",extends:["plugin:typescript/recommended"],}
interfaceFoo{foo?:number;}functionprint(x:Foo):void{console.log(x.foo)}print({bar:5}asFoo)

Expected Result

No errors.

Actual Result

/Users/semenov/tmp/ts-rule/test.ts  9:7  error  Type assertion on object literals is forbidden, use a type annotation instead  typescript/no-object-literal-type-assertion✖ 1 problem (1 error, 0 warnings)

Additional Info

The primary purpose of the rule (as I see it) is to prevent object assignment such asconst x = { ... } as T; which is better rewritten asconst x: T = { ...};, but the rule disallows all other legitimate uses.

Versions

packageversion
eslint-plugin-typescript1.0.0-rc.2
typescript-eslint-parser21.0.2
typescript3.2.2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp