It's legal, but not correct. The car would have the ModuleDependency, but at runtime it could also have other types. That's why it's wrong.

You must only use casts when the type is restricted at runtime but typescript doesn't know about that. Here the cast is useful to tell typescript that you are sure that this is the type here.