我试图回答another question about Flow,并且能够写出一个与OP所发现的内容相矛盾的示例。我想我发现了两个非常简单的示例,它们展示了Flow给出的两组错误,我认为是等效代码。我很乐意帮助您理解这是否是Flow的错误,或者我是否缺少区分这两个示例的东西。
type A_void = A => void;
type A_void_void = A_void => void;
type B_void = B => void;
type B_void_void = B_void => void;
interface A {
method: (A_void, A_void_void) => void;
}
class B implements A {
method: (B_void, B_void_void) => void;
}
type A_void = A => void;
type A_void_void = (A => void) => void
type B_void = B => void;
type B_void_void = (B => void) => void;
interface A {
method: (A_void, A_void_void) => void;
}
class B implements A {
method: (B_void, B_void_void) => void;
}
请注意,第一个错误仅产生一个错误-在B_void
中大约为B.method
-而第二个示例则产生两个错误-一个错误为B_void
,另一个错误为{{ 1}}在B_void_void
中。
据我了解,在B.method
中使用A_void
或A => void
作为类型并不重要,因为它们是等效的。但是,似乎它们会产生不同的错误。我希望示例2 是正确的,因为函数具有相反的输入。 A_void_void
和B_void
比B_void_void
和A_void
更具体,因此都应该引起错误。