flow-typed / flow-typed

A central repository for Flow library definitions
https://flow-typed.github.io/flow-typed/
MIT License
3.77k stars 1.33k forks source link

prototype augmentation in libraries #584

Closed Phoenixmatrix closed 2 years ago

Phoenixmatrix commented 7 years ago

More of a question than an issue. If I was to make a custom RxJS operator, that lived in a separate library and augments the prototype...what would the definition file for that look like? I've tried various ways of augmenting existing def with no luck.

endel commented 7 years ago

I have the same question. I'm trying to add a polyfill into Array, and flow throws me an error.

if (!Array.prototype.find) {
    Array.prototype.find = function(predicate) { ... }
}

Error:

inconsistent use of library definitions
  4:     Array.prototype.find = function(predicate) {
                         ^^^^ property `find`. Covariant property `find` incompatible with contravariant use in. See lib: animate/lib/Array.jsfl:4
  4:     Array.prototype.find = function(predicate) {
         ^^^^^^^^^^^^^^^^^^^^ assignment of property `find`. See lib: animate/lib/Array.jsfl:4