Maybe `typeReference == null` should be just `assert`