
type 和interface
即使不知道他们的区别,也是可以学习编程的。不要因为搞不懂type和interface的区别,而丧失了对编程的兴趣。
import type {XYZ} from ‘xxxx’
一般情况type和interface都很类似。
Both can be used to describe the shape of an object or a function signature. But the syntax differs.
https://blog.logrocket.com/types-vs-interfaces-typescript/
?:可选属性,?:说明这个属性可以不存在
errorMessage?: string;
最近有typescript和python代码互转的需求。
但是会发现除了基本的逻辑流程的转写,还涉及到数据结构的转写。而且数据结构的转写比逻辑的的转写有时候还要烧脑。
比如下面的typescript怎么转写成python的数据类型?
// Conversation tracking types for maintaining context across interactions
export interface ConversationMessage {
id: string;
role: 'user' | 'assistant';
content: string;
timestamp: number;
metadata?:

最低0.47元/天 解锁文章
591

被折叠的 条评论
为什么被折叠?



