我有一个对象的类型别名,A
:
type A = {
B: {
C: string
}
}
我想创建另一种类型的别名,B
pe,在A
中有B
财产的签名。
我试着用type B = A.B;
但流动引发以下错误:
[flow] [flow] B (Property cannot be accessed on type `A`)
我发现了一个解决方案,但它是一个有点棘手,不优雅可言:
type A = {
B: {
C: string
}
}
//FAKE constant of type A
const fakeA : A = (null : any);
type B = typeof fakeA.B;
任何其他解决办法?
感谢您的帮助。
请提供一些额外的上下文 - 这是什么语言?另外,当你说“它不起作用”时,你是否有任何错误,或者它不起作用? – Randall
此外,“流量”是一个元标签,通常不会被使用。应该有一个你正在使用的语言的标签。 – Randall
我正在使用JavaScript(ES6)和Flow。 –