Enforce consistent usage of type assertions.
// code-linter.json5
{
"rules": {
"@typescript-eslint/consistent-type-assertions": "error"
}
} // By default, ... as foo is recommended. Always prefer const x = { ... } as T; to const x = { ... } as T;.
interface MyType {
name: string;
}
export const x: MyType = {
name: 'hello'
};
export const y = x as object; // By default, ... as foo is recommended. Always prefer const x = { ... } as T; to const x = { ... } as T;.
interface MyType {
name: string;
}
export const x: MyType = {
name: 'hello'
};
export const y = <object>x; plugin:@typescript-eslint/all
For details about how to configure Code Linter check rules, see Code Linter Check.