【发布时间】:2021-03-02 03:53:46
【问题描述】:
假设我们定义了一个非常简单的对象类型:
type A = {
foo: string,
bar: number,
// ... many other properties
};
现在我们要定义这种类型的变体,只需将foo 的类型替换为?string:
type A2 = {
foo: ?string,
bar: number,
// ... many other properties, with the same types as in A
};
如何在不必重新定义整个类型的情况下做到这一点?
如果答案仅适用于将属性类型T 替换为?T 的特定情况就足够了,因为这是我最常遇到的问题。
【问题讨论】:
标签: javascript flowtype