Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method override doesn't work with union/intersection combination: (A | B) & C #7836

Open
cakoose opened this issue Jun 19, 2019 · 0 comments

Comments

@cakoose
Copy link
Contributor

cakoose commented Jun 19, 2019

Flow version: v0.101.0

// @flow
type Row = {rowId: string};
type Column = {columnId: string}

class A {
  f1(a: Array<Row | Column>) {}
  f2(a: Array<Row & {index: number}>) {}
  f3(a: Array<(Row | Column) & {index: number}>) {}
}

class B extends A {
  f1(a: Array<Row | Column>) {}                      // <-- no error (good!)
  f2(a: Array<Row & {index: number}>) {}             // <-- no error (good!)
  f3(a: Array<(Row | Column) & {index: number}>) {}  // <-- unexpected error
}

flow.org/try: link

14:   f3(a: Array<(Row | Column) & {index: number}>) {}      ^ Cannot extend `A` [1] with `B` because in array element of the first argument of property `f3`: Either property `rowId` is missing in `Column` [2] but exists in `Row` [3]. Or property `rowId` is missing in object type [4] but exists in `Row` [3]. Or property `columnId` is missing in `Row` [5] but exists in `Column` [6]. Or property `columnId` is missing in object type [4] but exists in `Column` [6].
References:
11: class B extends A {
                    ^ [1]
14:   f3(a: Array<(Row | Column) & {index: number}>) {}
                         ^ [2]
8:   f3(a: Array<(Row | Column) & {index: number}>) {}
                  ^ [3]
14:   f3(a: Array<(Row | Column) & {index: number}>) {}
                                   ^ [4]
14:   f3(a: Array<(Row | Column) & {index: number}>) {}
                   ^ [5]
8:   f3(a: Array<(Row | Column) & {index: number}>) {}
                        ^ [6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants