-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Document what mixins actually do #1383
Comments
I think this was primarily present to model React mixins, which are now deprecated, and I can't seem to find recent use of this. Might be worth checking if they can be removed from the codebase or if there is still code that uses it, and if so document it. |
mixins doesn't appear in the current doc website https://flow.org/en/docs/ but it was present in the doc at some point:
mode examples in the diff some more infos about mixins can be found in commits:
|
the page about mixins have been deleted by this commit.
it's hard to say if other content has been deleted, as this commit rename and rewrites a lot of files from the documentation website, but I have the impression that this commit removed some other useful content too (examples, etc). |
@TrySound why did you close this issue? Where is it documented? |
AFAIK mixins proposal was declined |
Could you reopen? |
Is there any way to use mixins with interfaces? Flowgen generates |
Flow rightly complains that React$ComponentType isn't a class, so it can't be extended (…er, or used with `mixins`, whatever that is: facebook/flow#1383 ). A value of type React$ComponentType *might* be a class, but it might be just a plain function.
Flow rightly complains that React$ComponentType isn't a class, so it can't be extended (…er, or used with `mixins`, whatever that is: facebook/flow#1383 ). A value of type React$ComponentType *might* be a class, but it might be just a plain function.
Close as mixin isn't planned to be well supported |
New syntax should be avoided. Instead, existing plain JavaScript mixins should be made to be super easy to define types for in Flow. This is a plain JavaScript mixin, which is very easy to implement in plain JavaScript: export function FooMixin(Base) {
return class Foo extends Base {
fooMethod() {...}
}
} You can use the mixin on any other class, even if it already extends another class, meaning you can change this, import {SomeBaseClass} from 'somewhere'
class MyClass extends SomeBaseClass {
myMethod() {...}
}
const o = new MyClass()
o.myMethod() // ok to this: import {SomeBaseClass} from 'somewhere'
import {FooMixin} from 'somewhere-else'
class MyClass extends FooMixin(SomeBaseClass) {
myMethod() {...}
}
const o = new MyClass()
o.myMethod() // ok
o.fooMethod() // new This is incredibly straight forward in plain JavaScript, and powerful for code re-use. However it is difficult in TypeScript, and much more difficult if not impossible in Flow. |
New issue for mixins: |
I have no idea what
mixins
do and how it works.I am adding this both as a documentation issue and as a cry for help, because I really don't know what it does. It seems it can be useful to me but I am not sure.
The text was updated successfully, but these errors were encountered: