禁止使用类型别名。
该规则仅支持对.js/.ts文件进行检查。
规则配置
// code-linter.json5
{
"rules": {
"@typescript-eslint/no-type-alias": "error"
}
} 正例
interface Person {
readonly firstName: string;
readonly lastName: string;
readonly age: number;
}
export function addPerson(person: Person): Person {
return person;
} 反例
// 不允许使用类型别名,建议使用接口替代
type Person = {
readonly firstName: string;
readonly lastName: string;
readonly age: number;
};
export function addPerson(person: Person): Person {
return person;
}