flowjs / flow.js

A JavaScript library providing multiple simultaneous, stable, fault-tolerant and resumable/restartable file uploads via the HTML5 File API.
Other
2.96k stars 346 forks source link

"new" operator #382

Closed Dagur closed 1 year ago

Dagur commented 1 year ago

I'm trying to add flow to some old code which has a lot of functions like this which are used with the new operator

function something() {
  this.a = ""
  this.b = ""
}

function main() {
  const thing = new something();
  return thing;
}

Let's say I want to give the main function a return type, how do I do that? I've tried typeof something and {a: string, b: string} but flow doesn't like either one and tells me

Cannot return `thing` because a call signature declaring the expected parameter / return type is missing in  new object [1] but exists in  function [2].Flow(prop-missing)
file.js(123, 44): [1] new object
file.js(123, 45): [2] function
command-tab commented 1 year ago

I think this is an issue meant for https://github.com/facebook/flow.

Dagur commented 1 year ago

Sorry 😅