-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DiscussionIssues which may not have code impactIssues which may not have code impact
Description
This is a somewhat "catch-all" issue to serve as a place of discussion for a question that is sure to come up given the advancement of Private-Named Instance Fields:
What is the future of the "private" keyword in TypeScript?
That's the general question - following are some short-and-sweet Q&As that I've pulled up for visibility.
Is TypeScript going to depreciate it, and aim towards phasing it out in favor of the private field operator?
Our current plan is to leave the current private behavior as-is.
Is it going to be supported in the form of a transformer , turning private bar
into #bar
?
definitely "no" because that would require type-directed emit.
A few more questions:
Would #-fields allow modifiers like readonly?
Will public #x, private #x and protected #x be an error?
Will it be possible to assign #-fields from the constructor parameters, the same way as the current parameter-properties work (i.e., constructor (private x) and constructor (#x))?
What visibility rules will apply between private entities and #-entities? What if I use a private-entity from a #-entity, or vice versa? Seems that #-entites are 'more' private than private-entities, in some sense. :)
The visibility of a method doesn't change which properties it's allowed to access
Would it be possible to do the following:
class Foo {
bar: string;
#baz: number;
}
const foo: Foo = { bar: 'bar' };
levenleven, FranDias, pioluk, karol-majewski, pubkey and 23 moreWhiteAbeLincoln, basarat, piotrl, Schubidu, michalczukm and 6 more
Metadata
Metadata
Assignees
Labels
DiscussionIssues which may not have code impactIssues which may not have code impact