首页 前端知识 TypeScript 中 type 如何像 interface来使用extends(继承)

TypeScript 中 type 如何像 interface来使用extends(继承)

2024-05-24 08:05:09 前端知识 前端哥 202 209 我要收藏

TypeScript 中 type 如何像 interface来使用extends(继承)

interface

interface 定义类型的时候可以直接使用 extends 来进行继承

// interface.ts
export interface IExample {
	data: Array<string>;
}

export interface ITreeData {
	stackList: IExample;
	a?: string;
	b?: string;
}

export interface IGloble extends ITreeData {
	c: string;
}

Type

type 则需要使用 &

// interface.ts
export interface IExample {
	data: Array<string>;
}

export interface ITreeData {
	stackList: IExample;
	a?: string;
	b?: string;
}
export type ISimpleTraceRenderProps = TreeProps & {
	c: string;
}
转载请注明出处或者链接地址:https://www.qianduange.cn//article/9313.html
标签
接口
评论
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!