Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
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
package | version |
---|---|
eslint-plugin-typescript | 1.0.0-rc.2 |
typescript-eslint-parser | 21.0.2 |
typescript | 3.2.2 |