是否有禁止前缀类型断言语法的 TSLint 规则?

Is there a TSLint rule that forbids the prefixed type assertion syntax?

类型断言可以用两种方式描述:

  1. 前缀
<Foo>{ foo: 'bar' };
  1. 后缀
{ foo: 'bar' } as Foo;

是否有禁止前者而强制执行后者的 TSLint 规则?

TSLint 对此有一个内置规则:no-angle-bracket-type-assertion

要启用,请将规则添加到您的 tslint.json,如下所示

{
  "rules": {
    "no-angle-bracket-type-assertion": true
  }
}

规则有一个自动修复程序。