Skip to content

Latest commit

 

History

History
61 lines (50 loc) · 1.21 KB

File metadata and controls

61 lines (50 loc) · 1.21 KB
sidebarDepth categories tags
0
TypeScript
TSLint
TypeScript

ban-types

禁止使用特定的类型作为类型声明,如 Function, Object, String, Number 等 JavaScript 构造函数,而应该使用 () => void, object, string, number 等 TypeScript 类型声明关键字。

规则详情

  • 本规范中的配置
{
  "ban-types": [
    true,
    ["Object", "Avoid using the `Object` type. Did you mean `object`?"],
    ["Function", "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."],
    ["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
    ["Number", "Avoid using the `Number` type. Did you mean `number`?"],
    ["String", "Avoid using the `String` type. Did you mean `string`?"],
    ["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"]
  ]
}
interface Foo {
  a: Object;
  b: Function;
  c: Boolean;
  d: Number;
  e: String;
  f: Symbol;
}
interface Foo {
  a: object;
  b: () => void;
  c: boolean;
  d: number;
  e: string;
  f: symbol;
}