定义数组类型时,建议使用相同的样式。比如都使用T[]或者都使用Array<T>。
规则配置
// code-linter.json5
{
"rules": {
"@typescript-eslint/array-type": "error"
}
} 正例
const x: string[] = ['a', 'b'];
const y: readonly string[] = ['a', 'b'];
export { x, y }; 反例
const x: Array<string> = ['a', 'b'];
const y: ReadonlyArray<string> = ['a', 'b'];
export { x, y };