DEV Community

Discussion on: 11 Tips That Make You a Better Typescript Programmer

Collapse
 
joshuakb2 profile image
Joshua Baker

Are you sure that's true? I recently heard that that's actually a myth.

Collapse
 
joshkel profile image
Josh Kelley

If I understand github.com/microsoft/TypeScript/wi... correctly, types aren't universally slower, but once you start doing more complex type unions and intersections, it can be faster to use interfaces.

Thread Thread
 
ymc9 profile image
ymc9

That's my understanding too.

I believe it's mainly due to this statement: "A final noteworthy difference is that when checking against a target intersection type, every constituent is checked before checking against the "effective"/"flattened" type." Though it feels like a limitation of the current tsc implementation, I don't see why checking of type intersection has to be done repeatedly instead of cached.

Would love to see some benchmarks.

Some comments have been hidden by the post's author - find out more