- Notifications
You must be signed in to change notification settings - Fork13.2k
ES private class elements#42458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
rbuckton merged 87 commits intomicrosoft:masterfrombloomberg:es-private-methods-and-accessorsMar 25, 2021
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
87 commits Select commitHold shift + click to select a range
e3a3fb8 Added support for private identifier methods.
dragomirtitian4ab27a2 Added tests for private methods.
dragomirtitian6977b9f Added check to only not allow private name method signatures in anyth…
dragomirtitianbc8c07e Added private accessors tests
dragomirtitian2760ed8 Transform private methods
mkubilayk04af85d Rename shouldTransformPrivateFields
mkubilaykf048d72 Accept baseline
mkubilaykf8cfb81 Use a single WeakSet for brand-check
mkubilayk4aa4c3b Accept baseline
mkubilayk0ac1271 Add a test for using private methods in static field initializers
mkubilayk7da5bd9 Add breaking checker test
mkubilayke133f60 Add to instances once per-instance
mkubilaykaa5dd8a Accept baseline
mkubilayka3889a7 fix: evaluate receiver and rhs expressions before throwing on readonl…
mkubilayk8952caa Add a test for evaluating rhs before readonly assignment
mkubilaykdee87bb Transpile private accessors
mkubilaykaec7e9b Accept baseline
mkubilaykf3bbf0f fix: handle readonly/writeonly accessors
mkubilayka1b59cd accept baseline
mkubilayk6b74498 add a test for private setter without a getter
mkubilaykd51f6cd fix: getAllUnscopedEmitHelpers
mkubilaykc175770 fix: better handling of duplicate names
mkubilayk4301af5 Fixed wrong error message for private methods in class expressions.
dragomirtitian3a056b2 change error message
mkubilayk95df2d1 add a test for async private methods with a higher target
mkubilayk590124e fix: setter assignment returns rhs value
mkubilayk219ea83 add a test for setter assignment return value
mkubilayk25da8ca fix: handle duplicate accessors
mkubilayka2228be add tests for duplicate accessors
mkubilaykff4f737 docs: add missing parameter docs
mkubilayk704727c Fixed failing test.
dragomirtitian73925dc baseline-accept: ordering changes
mkubilayk67fd38d fix: attach weakSetName to property declaration
mkubilayk45c2a41 add a test for nested private methods
mkubilayk356b91d add a test with any
mkubilaykb391464 Merge pull request #51 from bloomberg/fix/nested-private-methods
dragomirtitian5ebb3d6 Added support for static private fields accessors and methods.
dragomirtitian7006c09 Added error message for private identifiers used with static decorato…
dragomirtitianb876613 Fixed emit static bug that used private names outside of classes for …
dragomirtitian31a8c00 Added tests for private static fields methods and accessors.
dragomirtitian9219e99 Merge remote-tracking branch 'remotes/origin/master' into es-private-…
dragomirtitian5a27a32 Merge remote-tracking branch 'remotes/bloomberg/es-private-methods-an…
dragomirtitian964fc27 Fixed error messages and tests after merge.
dragomirtitiand2ab6fc Merge branch 'es-private-methods-and-accessors' into es-private-stati…
dragomirtitian23f6c67 Accept new baseline.
dragomirtitian374e6f3 Improved duplicate identifier checks for static private class elements.
dragomirtitian62b4f2f Added error when using initializers with private static fields when u…
dragomirtitianb2a692d Fixed code review issues.
dragomirtitian363041e Removed semantically wrong emit on `useDefineForClassFields:true` wit…
dragomirtitian64757e0 Changed emit for uninitialized private static fields.
dragomirtitian68a7f80 Added runtime error in helper if a static private field is accessed b…
dragomirtitian7e7b0b1 Fixed code review comments for private identifier static class elements.
dragomirtitian30c7f69 add debug.assertNever for unknown node type (#53)
mkubilaykc924058 Merge remote-tracking branch 'upstream/master' into es-private-method…
mkubilayke65116f Merge remote-tracking branch 'upstream/master' into es-private-method…
mkubilayk4748c87 Fixed code review issues.
dragomirtitian09a5aae Merge branch 'es-private-methods-and-accessors' into es-private-stati…
dragomirtitian497e47f Fixed code review issues for private class elements.
dragomirtitian294cc48 Fixes class shadowing when checking access to a private static class …
dragomirtitian027bdb3 Merge remote-tracking branch 'remotes/origin/master' into es-private-…
dragomirtitian7bbc944 Merge remote-tracking branch 'upstream/master'
mkubilaykdd526e7 fix private methods/accessors in class expr inside a loop
mkubilaykf6ecfab collapse switch case
mkubilayk6c3f661 fix class name
mkubilaykef69c6c simplify getPrivateMethodsAndAccessors
mkubilayk2a646ed remove findPreviousAccessorInfo
mkubilaykd8136f7 lazily create weakSetName identifier
mkubilaykfbd749c Merge remote-tracking branch 'remotes/bloomberg/es-private-static-fie…
dragomirtitianf96eafe Merge remote-tracking branch 'remotes/bloomberg/es-private-static-fie…
dragomirtitian2de8a43 Merge branch 'es-private-methods-and-accessors' of https://github.com…
dragomirtitian7490a36 do not allocate a node if not needed in visitMehodDeclaration (#55)
mkubilaykc273258 Removed all the emit helpers for private identifier methods accessors…
dragomirtitian1addbb3 Simplified emit for private identifier class elements.
dragomirtitianc461b92 do not clone the receiver (#57)
mkubilayka61fd5f leave bad code in for #constructor and duplicate private names (#58)
mkubilayk89f746a Added check for WeakSet collision.
dragomirtitianff24636 Added error for using a set only accessor.
dragomirtitiana60e429 Merge pull request #61 from bloomberg/es-private-methods-and-accessor…
dragomirtitianf5816ab update keyof tests and ?? (#62)
mkubilayk3b62d3c fix emit helpers comments
mkubilayk7d8a2b9 produce an error if private field helpers are not up to date
mkubilaykd0d2055 add tests
mkubilayk93a7ca3 fix setter-only compound assignment
mkubilayk6da2cdd Merge pull request #63 from bloomberg/helper-parameter-count
mkubilayk30805b7 fix tests
mkubilayk8d77a8e fix duplicated trailing comments (#64)
mkubilayk8078ae0 clear receiver pos and setTextRange on helper calls
mkubilaykFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Add a test for using private methods in static field initializers
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit0ac12711a50ec5422d8db0edf49346f14636f9af
There are no files selected for viewing
25 changes: 25 additions & 0 deletionstests/baselines/reference/privateNameMethodInStaticFieldInit.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //// [privateNameMethodInStaticFieldInit.ts] | ||
| class C { | ||
| static s = new C().#method(); | ||
| #method() { return 42; } | ||
| } | ||
| console.log(C.s); | ||
| //// [privateNameMethodInStaticFieldInit.js] | ||
| var __classPrivateMethodGet = (this && this.__classPrivateMethodGet) || function (receiver, instances, fn) { | ||
| if (!instances.has(receiver)) { | ||
| throw new TypeError("attempted to get private method on non-instance"); | ||
| } | ||
| return fn; | ||
| }; | ||
| var _C_method, _C_instances, _a; | ||
| class C { | ||
| constructor() { | ||
| _C_instances.add(this); | ||
| } | ||
| } | ||
| _C_instances = new WeakSet(), _C_method = function _C_method() { return 42; }; | ||
| C.s = __classPrivateMethodGet((_a = new C()), _C_instances, _C_method).call(_a); | ||
| console.log(C.s); |
21 changes: 21 additions & 0 deletionstests/baselines/reference/privateNameMethodInStaticFieldInit.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| === tests/cases/conformance/classes/members/privateNames/privateNameMethodInStaticFieldInit.ts === | ||
| class C { | ||
| >C : Symbol(C, Decl(privateNameMethodInStaticFieldInit.ts, 0, 0)) | ||
| static s = new C().#method(); | ||
| >s : Symbol(C.s, Decl(privateNameMethodInStaticFieldInit.ts, 0, 9)) | ||
| >new C().#method : Symbol(C.#method, Decl(privateNameMethodInStaticFieldInit.ts, 1, 33)) | ||
| >C : Symbol(C, Decl(privateNameMethodInStaticFieldInit.ts, 0, 0)) | ||
| #method() { return 42; } | ||
| >#method : Symbol(C.#method, Decl(privateNameMethodInStaticFieldInit.ts, 1, 33)) | ||
| } | ||
| console.log(C.s); | ||
| >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
| >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
| >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
| >C.s : Symbol(C.s, Decl(privateNameMethodInStaticFieldInit.ts, 0, 9)) | ||
| >C : Symbol(C, Decl(privateNameMethodInStaticFieldInit.ts, 0, 0)) | ||
| >s : Symbol(C.s, Decl(privateNameMethodInStaticFieldInit.ts, 0, 9)) | ||
25 changes: 25 additions & 0 deletionstests/baselines/reference/privateNameMethodInStaticFieldInit.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| === tests/cases/conformance/classes/members/privateNames/privateNameMethodInStaticFieldInit.ts === | ||
| class C { | ||
| >C : C | ||
| static s = new C().#method(); | ||
| >s : number | ||
| >new C().#method() : number | ||
| >new C().#method : () => number | ||
| >new C() : C | ||
| >C : typeof C | ||
| #method() { return 42; } | ||
| >#method : () => number | ||
| >42 : 42 | ||
| } | ||
| console.log(C.s); | ||
| >console.log(C.s) : void | ||
| >console.log : (...data: any[]) => void | ||
| >console : Console | ||
| >log : (...data: any[]) => void | ||
| >C.s : number | ||
| >C : typeof C | ||
| >s : number | ||
8 changes: 8 additions & 0 deletionstests/cases/conformance/classes/members/privateNames/privateNameMethodInStaticFieldInit.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // @target: es2015 | ||
| class C { | ||
| static s = new C().#method(); | ||
| #method() { return 42; } | ||
| } | ||
| console.log(C.s); |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.