Fix Your Typescript: You Have The Wrong Privates

Опубликовано: 17 Июль 2026
на канале: Tech Turn
22
1

JavaScript has evolved, and this video explains why engineers should stop relying on TypeScript’s private keyword and start using native JavaScript private class fields with the # syntax. While TypeScript’s private looks like real encapsulation, it disappears at compile time and offers no runtime protection. Once the code is running, those fields are just normal properties that can still be accessed or modified.

Native private fields, on the other hand, are enforced directly by the JavaScript engine. They are truly inaccessible from outside the class, throw runtime errors when misused, and clearly express intent in the code. The video also covers performance, showing how testing and benchmarks demonstrate that native private fields can be as fast as, or faster than, public properties in modern JavaScript engines.

Chapters
00:00 Intro
01:56 Performance of Private vs Public Variables
07:24 Consistency in a Codebase
08:25 Handing Legacy Code
08:51 Final Thoughts