These are chat archives for DefinitelyTyped/DefinitelyTyped

Jan 2017
Pat Sissons
Jan 25 2017 03:50
running into a strange issue with the new react types and the now ReadOnly<S> state typing.
this is essentially the issue:
class Test {
  // comment out this private member to fix the issue
  private privVal = '';
  public pubVal = '';

function broken() {
  let ro: Readonly<Test>;
  let rw: Test;
  ro = rw;
  // fails covariance
  rw = ro;
in my case, my React.Component<P, S> use an interface for P but a class for S, these classes all have private members, which means that i can no longer assume my state is an S. I'm guessing this is a heavy handed way of saying don't use classes for your generic type parameters, but wanted to confirm that is the intent.
Pat Sissons
Jan 25 2017 23:33
for reference, this issue is (better) captured here: Microsoft/TypeScript#13692