Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k views
in Technique[技术] by (71.8m points)

请问typescript如何实现接口中包含泛型类的所有属性

代码如下:

interface WithTime<T extends Object>{
  time:string;
  //这里添加一些代码,实现包含泛型T中的所有属性
}

ts初学者,请问各位大佬这个要怎么实现,万分感谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

问题已解决,代码如下:
type WithTime<T> = {time:string}&T


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...