typescript 中 [propName: string]的使用

其他没有使用的属性名 可以统一使用[propName: string]: number | string | boolean | Array;定义类型 属性值的类型是把所有的类型都展示

interface DataState {
    id: number | string;
    createTime: number;
    commentUserAvatar: string;
    commentDeleted: boolean;
    commentUserName: string;
    commentImages: Array<string>;
    resourceUserAvatar: string;
    fromName: string;
    relatedCommentContent: string;
    relatedCommentDeleted: boolean;
    relatedCommentUserName: string;
    resourceDeleted: boolean;
    resourceTitle: string;
    [propName: string]: number | string | boolean | Array<string>;
}

你可能感兴趣的:(笔记,typescript,typescript,javascript,前端)