【发布时间】:2020-09-03 19:36:46
【问题描述】:
打字稿类型别名可以支持默认参数吗?例如:
export type SomeType = {
typename: string;
strength: number;
radius: number;
some_func: Function;
some_other_stat: number = 8; // <-- This doesn't work
}
错误是A type literal property cannot have an initializer.
我找不到与此相关的文档 - type 关键字在其他所有也称为类型的东西后面都非常晦涩难懂。我可以做些什么来为打字稿中的type 设置默认参数值吗?
【问题讨论】:
标签: typescript types type-alias