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
- TypeScript Structured Concurrencythecandidstartup.org
- Configuring ESLint and Prettier for TypeScriptyoutube.com
- TypeScript: Documentation - TypeScript for the New Programmertypescriptlang.org
- Tao of React - Software Design, Architecture & Best Practices | Alex Kondovalexkondov.com
- TypeScript: Handbook - Enumstypescriptlang.org
- TypeScript: Documentation - The Basicstypescriptlang.org
- Defining an Enum - The Rust Programming Languagedoc.rust-lang.org
- Demystifying Code Bundling with JavaScript Modules - Simple Threadsimplethread.com
- TypeScript: Documentation - TypeScript 3.7typescriptlang.org
- Tensor Considered Harmfulnlp.seas.harvard.edu
- Tao of Node - Design, Architecture & Best Practices | Alex Kondovalexkondov.com
- TypeScript: Documentation - TypeScript 3.8typescriptlang.org