flâneur

David Zearing - HackMD

hackmd.io · 215 words · saved by 1 readers

Best way to write and share your knowledge in markdown.

Why are const enums bad? I always forget why, so time to write it down! They interfere with isolatedModules support and transpilers. Imagine that a transplier will convert your TypeScript code into Javascript, without parsing the typings of the dependencies. That means if you import { SomeConstEnum } from 'dependency' in your code, it doesn't know it's a const enum, or an interface, or a js object, and as such the transpiler leaves the import there. The problem with this is that now, if you parse the javascript you just emitted, the named import will fail. In the raw JavaScript ES module…

saved by

related reading