I understand that Record creates a new class. Why then does the following typecheck in Flow:
const Person = Record({fname : null, lname: null});
const Person2 = Record({fnameMANGLED: null, lname: null});
const p : Person2 = new Person({fname: 'joe', lname: 'doe'}); // shouldn't Flow complain?
In contrast, when using ordinary classes, the following doesn't typecheck (as expected):
class A{constructor() {}};
class B{constructor() {}};
const a: A = new A();
It's because in the current type definitions of immutable JS, Record factory constructor returns
any
.If you uncomment the line
/*T & Record<T>*/
it catches the error as expected.