question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Port TS "Private" Variables to JavaScript Private Variables

See original GitHub issue

Is your feature request related to a problem? Please describe.

TypeScript’s private class property modifier is only checked when you are using TypeScript and the encapsulation is lost through compilation. Furthermore, we’re assuming that someone didn’t cast something as any along the line in which “private” variables are not private at all.

Describe the solution you’d like

I think that it would be best if we migrate all instances of private class properties to using the ES6 Private Variable syntax (#___) to help mitigate the chances of users having unexpected bugs because they were using a property in their JavaScript (or any-typed TypeScript). Also, this would help stop even more important mass code breakages from libraries using these private variables irresponsibly and causing issues for their unsuspecting users.

Describe alternatives you’ve considered

n/a

I am willing to work on this.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lino-levancommented, Nov 1, 2022

I feel like this issue should be resolved as the private identifier no longer exists in std as far as I can tell.

1reaction
bartlomiejucommented, Nov 30, 2021

@sno2 feel free to start with code in node/ and io/buffer.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript Class with private variables - Stack Overflow
Can you try with the typescript code below . Updated my answer. ts file class Ticket { private form: HTMLFormElement; constructor(elem: ...
Read more >
Implementing Private Variables In JavaScript - CSS-Tricks
In its current state, there is no “direct” way to create a private variable in JavaScript. In other languages, you can use the...
Read more >
Handbook - Classes - TypeScript
This class has three members: a property called greeting , a ... TypeScript supports the new JavaScript syntax for private fields: ts.
Read more >
How to create a private variable in JavaScript ? - GeeksforGeeks
In this article, we will try to understand how we could create private variables in JavaScript. Let us first understand what are the...
Read more >
Unit testing private variables and functions in JavaScript
When is it okay to Unit Test private variables and functions in JavaScript? Asking this question might be a sign of underlying design...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found