I am trying to add Flow types to this code example, where a Proxy sets a default for the first argument of a function
let panda = {
fn: function(n: number, s: string) {
console.log(n, s);
}
}
let handler = {
get: function(target,name) {
return (s) => target[name](1, s)
}
}
let g = new Proxy(panda, handler)
g.fn('k')
Here Flow complains forcing me to type invalid code.
// WRONG, but it is what Flow wants
// g.fn(2, 'k')
How can I get Flow to properly identify my Proxy?
This is the error I get with the good version:
19: g.fn('k')
^^^^^^^^^ call of method `fn`
19: g.fn('k')
^^^ string. This type is incompatible with
4: fn: function(n: number, s: string) {
^^^^^^ number
Closing since we currently planning on adding support for proxies.
@calebmer Which issue should I follow to track this feature and find out when it will be released?
Can this be re-opened if these is no other issue to track?
Still no progress after almost 4 years? Just ran into this issue. Unless I'm doing something blatantly wrong? New to type systems and it hasn't been as easy as the whitepapers make it seem.
Code example:
constructor(): Proxy<FlowInterface> {}
Error:
Cannot return `new Proxy(...)` because `FlowInterface` [1] is incompatible with `Proxy` [2].Flow(incompatible-return)
Changing to this fixes the problem:
constructor(): Proxy<any> {}
Most helpful comment
@calebmer Which issue should I follow to track this feature and find out when it will be released?