Typescript '"void" should not be used' triggers wrongly