4 ms·
you can "x as unknown as Whatever" anywhere in the code as well. Or just use @ts-ignore You can do this kind of thing in "proper" statically typed languages as
by DanielHB 3y ago
you can "x as unknown as Whatever" anywhere in the code as well. Or just use @ts-ignore
You can do this kind of thing in "proper" statically typed languages as well like "(Whatever)((Object)x)
The main problem in TS vs Java for this specific case is that if x is NOT Whatever then you get an error some point later in the code. In Java you would get the error immediately at the casting.
It makes debugging a bit trickier but I don't really run into these kind of problems all that often in my TS code and when I do they are usually easy to track down.