| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…ing except classes. Changes objects literal checking to not bail on first private name found in object literal.
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Private methods inside class expressions should not error. Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
…y assignment Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
produce an error if private field helpers are not up to date
|
Created microsoft/tslib#146 for tslib updates. Ron Buckton (@rbuckton) thanks for the review again. I think this is ready for another round. |
Sorry, something went wrong.
There was a problem hiding this comment.
The proposed changes (as well as relevant changes in createPrivateIdentifierAssignment) should address the comment issue.
Sorry, something went wrong.
|
Ron Buckton (@rbuckton) Thanks a lot for taking the time to debug this. I made the changes you suggested. |
Sorry, something went wrong.
|
|
||
| // leave invalid code untransformed | ||
| const info = accessPrivateIdentifier(node.name); | ||
| Debug.assert(info, "Undeclared private name for property declaration."); |
There was a problem hiding this comment.
Can a user write source text that would fail this assertion?
Sorry, something went wrong.
There was a problem hiding this comment.
I don't think so. That would indicate a bug in addPrivateIdentifierToEnvironment.
Sorry, something went wrong.
|
This has been a tremendous effort. I'm happy to see these changes go in and look forward to the community having a chance to test them in nightlies starting tomorrow! |
Sorry, something went wrong.
|
Congrats! Great work! |
Sorry, something went wrong.
|
The nightly playground build just shipped for folks interested in playing with it. Also congrats, serious work this. |
Sorry, something went wrong.
|
Hello, why is vs code still saying "A method cannot be named with a private identifier."? Shouldn't it stop since this PR has been merged since quite some time now? |
Sorry, something went wrong.
Hi Daniel (@danieltroger), private methods will be part of TypeScript 4.3 which is still in Beta. |
Sorry, something went wrong.
|
Ashley Claymore (@acutmore) I see, thank you for the swift reply. Any idea when it will be released? I feel like it will, even after the release, still take a long time until it lands in editors :( Is it easy to switch to beta? I'm mainly using atom and https://github.com/TypeStrong/atom-typescript |
Sorry, something went wrong.
4.3 is likely to be released at the end of May #42762
The atom-typescript docs say you can use a specific version of TypeScript by installing it. npm install typescript@4.3.0-beta |
Sorry, something went wrong.
|
Yo it worked, finally no red, thanks a lot! I got into npm conflict hell tho |
Sorry, something went wrong.
|
When is ETA? It is horrible microsoft/vscode#106351 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Private Class Elements
This PR implements the TC39 Stage-3 Private Methods and Accessors proposal as well as TC39 Stage 3 Static Class features.
Fixes #39066, #37677, #42985
Remaining Work
Downlevel
WeakSets are used for instance private methods and accessors, in the same way that the existing Private Fields downlevel uses WeakMaps.
Instance Private Methods and AccessorsTypeScript
JavaScript - ES2020 emit
JavaScript - ES2020 emit
References
Wider Contributions
Development of this PR led to these bug discoveries and fixes in other projects:
Credits
This PR includes contributions from the following Bloomberg engineers:
Design Limitations & Open Questions
-
-
ExampleThe pre-existing class fields transform can produce valid JavaScript from a syntactically invalid input. One example of this is duplicate private names. A similar issue will be visible in #constructor test since we now transform private methods. What is the desired TypeScript behavior in this case?
This implementation does not work with the experimental Decorators in TypeScript. There is no spec for the interaction between these two features and implementing something non-standard that is likely to break in the future does not seem useful. Therefore we issue an error if a Decorators is used on a class containing a static private field/method/accessor.
Initializers are not allowed if target: esnext AND useDefineForClassFields: false. This is due to the fact that initializing private fields outside of a class is a non-trivial transform (a possible solution is described here - a modified version of it could be applied if there is desire for this combination to allow it) and keeping the init in the class would change runtime ordering of initializers.
this is not allow in static initialization expressions. The restriction is a pre-existing issue and so is considered out-of-scope of this PR.
Unlike instance #private class elements, static #private class elements do not depend on WeakMap or WeakSet. This means that technically we could transpile static #private class elements for es5 or even es3. However having different requirements for instance vs static #private class elements would probably cause more confusion than benefit. Therefore we retain the existing minimum target of es2015 for using static #private class elements and will error otherwise.