Factor out type assertions.