Member-only story

It is nice to use public keyword in TypeScript

Tom Smykowski
Nov 17, 2021

--

On default, properties and methods of a class are public in TypeScript. So, you don’t have to add a public keyword. However, it is pleasant to use that keyword. Because based on OOP rules, properties and methods should be private on default. By using public keyword for public members you make it visible what members are in fact public, and also that you have exposed them willingly, and not by accident.

--

--

Tom Smykowski
Tom Smykowski

Written by Tom Smykowski

🚀 Senior/Lead Frontend Engineer | Angular · Vue.js · React | Design Systems, UI/UX | Looking for a new project! 📩 contact@tomasz-smykowski.com

No responses yet