Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Latest commit

 

History

History
31 lines (21 loc) · 684 Bytes

no-object-literal-type-assertion.md

File metadata and controls

31 lines (21 loc) · 684 Bytes

Forbids an object literal to appear in a type assertion expression (no-object-literal-type-assertion)

Always prefer const x: T = { ... }; to const x = { ... } as T;. Casting to any and unknown is still allowed.

Rule Details

Examples of incorrect code for this rule.

const x = { ... } as T;

Examples of correct code for this rule.

const x: T = { ... };
const y = { ... } as any;
const z = { ... } as unknown;

Options

{
    "typescript/no-object-literal-type-assertion": "error"
}

Compatibility