Open STRML opened 8 years ago
Flow is able to handle cyclical imports, but once these type imports are reified into real imports, it can cause problems in real apps.
For example:
A.js
import type {Foo} from './B' export default class Base { fn(a: Foo) { return a } }
B.js
import A from './A' export type Foo = Object; export default class B extends A {}
In this case you'll get something like:
inherits.js:9 Uncaught TypeError: Super expression must either be null or a function, not undefined
because the superclass isn't defined yet due to the cycle.
I've added the stub of a test here.
Not sure how to handle this - for basic type exports, it could be mitigated by creating a new file, moving all typedefs into that file, then importing that file from the base and all importers, but for instanceof checks it's significantly trickier.
instanceof
Flow is able to handle cyclical imports, but once these type imports are reified into real imports, it can cause problems in real apps.
For example:
A.js
B.js
In this case you'll get something like:
because the superclass isn't defined yet due to the cycle.
I've added the stub of a test here.
Not sure how to handle this - for basic type exports, it could be mitigated by creating a new file, moving all typedefs into that file, then importing that file from the base and all importers, but for
instanceof
checks it's significantly trickier.