Hacker News new | ask | show | jobs
by jenadine 1201 days ago
> #private: […] This is not recommended for TypeScript projects, instead just use the existing private keyword.

Why not? I was told the opposite: now that the feature is in JS natively, it can be used.

2 comments

The Deno style guide encourages the use of `#prop` over `private prop` [0]. Other guides such as the Google TypeScript Guide discourages their use [1] for now because they are transpiled to slow code.

What I could conclude is: use `#` over `private` for runtimes that support them or projects that can target recent runtimes and browsers.

[0] https://deno.land/manual@v1.29.3/references/contributing/sty...

[1] https://google.github.io/styleguide/tsguide.html#private-fie...

Probably so that tsc can transpile it differently for older browsers.