typescript test if object implements interface