Commit e638af7
ES private class elements (#42458)
* Added support for private identifier methods.
* Added tests for private methods.
* Added check to only not allow private name method signatures in anything except classes.
Changes objects literal checking to not bail on first private name found in object literal.
* Added private accessors tests
* Transform private methods
Signed-off-by: Kubilay Kahveci <[email protected]>
* Rename shouldTransformPrivateFields
Signed-off-by: Kubilay Kahveci <[email protected]>
* Accept baseline
Signed-off-by: Kubilay Kahveci <[email protected]>
* Use a single WeakSet for brand-check
Signed-off-by: Kubilay Kahveci <[email protected]>
* Accept baseline
Signed-off-by: Kubilay Kahveci <[email protected]>
* Add a test for using private methods in static field initializers
Signed-off-by: Kubilay Kahveci <[email protected]>
* Add breaking checker test
Private methods inside class expressions should not error.
Signed-off-by: Kubilay Kahveci <[email protected]>
* Add to instances once per-instance
Signed-off-by: Kubilay Kahveci <[email protected]>
* Accept baseline
Signed-off-by: Kubilay Kahveci <[email protected]>
* fix: evaluate receiver and rhs expressions before throwing on readonly assignment
Signed-off-by: Kubilay Kahveci <[email protected]>
* Add a test for evaluating rhs before readonly assignment
Signed-off-by: Kubilay Kahveci <[email protected]>
* Transpile private accessors
Signed-off-by: Kubilay Kahveci <[email protected]>
* Accept baseline
Signed-off-by: Kubilay Kahveci <[email protected]>
* fix: handle readonly/writeonly accessors
Signed-off-by: Kubilay Kahveci <[email protected]>
* accept baseline
Signed-off-by: Kubilay Kahveci <[email protected]>
* add a test for private setter without a getter
Signed-off-by: Kubilay Kahveci <[email protected]>
* fix: getAllUnscopedEmitHelpers
Signed-off-by: Kubilay Kahveci <[email protected]>
* fix: better handling of duplicate names
Signed-off-by: Kubilay Kahveci <[email protected]>
* Fixed wrong error message for private methods in class expressions.
* change error message
Signed-off-by: Kubilay Kahveci <[email protected]>
* add a test for async private methods with a higher target
Signed-off-by: Kubilay Kahveci <[email protected]>
* fix: setter assignment returns rhs value
Signed-off-by: Kubilay Kahveci <[email protected]>
* add a test for setter assignment return value
Signed-off-by: Kubilay Kahveci <[email protected]>
* fix: handle duplicate accessors
Signed-off-by: Kubilay Kahveci <[email protected]>
* add tests for duplicate accessors
Signed-off-by: Kubilay Kahveci <[email protected]>
* docs: add missing parameter docs
Signed-off-by: Kubilay Kahveci <[email protected]>
* Fixed failing test.
* baseline-accept: ordering changes
Signed-off-by: Kubilay Kahveci <[email protected]>
* fix: attach weakSetName to property declaration
Signed-off-by: Kubilay Kahveci <[email protected]>
* add a test for nested private methods
Signed-off-by: Kubilay Kahveci <[email protected]>
* add a test with any
Signed-off-by: Kubilay Kahveci <[email protected]>
* Added support for static private fields accessors and methods.
* Added error message for private identifiers used with static decorators. There is no spec to go with this behavior as of yet.
* Fixed emit static bug that used private names outside of classes for initialization in esnext. Fixed issue where nested privates produce incorrect brand check.
* Added tests for private static fields methods and accessors.
* Fixed error messages and tests after merge.
* Accept new baseline.
* Improved duplicate identifier checks for static private class elements.
* Added error when using initializers with private static fields when useDefineForClassFields is not specified and target is esnext.
* Fixed code review issues.
* Removed semantically wrong emit on `useDefineForClassFields:true` with `target:esnext`
* Changed emit for uninitialized private static fields.
* Added runtime error in helper if a static private field is accessed before it was declared.
* Fixed code review comments for private identifier static class elements.
* add debug.assertNever for unknown node type (#53)
* Fixed code review issues.
* Fixed code review issues for private class elements.
* Fixes class shadowing when checking access to a private static class element.
* fix private methods/accessors in class expr inside a loop
* collapse switch case
* fix class name
* simplify getPrivateMethodsAndAccessors
* remove findPreviousAccessorInfo
* lazily create weakSetName identifier
* do not allocate a node if not needed in visitMehodDeclaration (#55)
* Removed all the emit helpers for private identifier methods accessors and modified the existing helpers for get and set fields to do the same job.
* Simplified emit for private identifier class elements.
* do not clone the receiver (#57)
* leave bad code in for #constructor and duplicate private names (#58)
* Added check for WeakSet collision.
* Added error for using a set only accessor.
* update keyof tests and ?? (#62)
* replace ?? with ||
* update keyof tests
* fix emit helpers comments
* produce an error if private field helpers are not up to date
* add tests
* fix setter-only compound assignment
* fix tests
* fix duplicated trailing comments (#64)
* clear receiver pos and setTextRange on helper calls
Co-authored-by: Kubilay Kahveci <[email protected]>1 parent 6ce82ab commit e638af7
File tree
370 files changed
+15654
-1223
lines changed- src
- compiler
- factory
- transformers
- services
- tests
- baselines/reference
- cases
- compiler
- conformance/classes/members/privateNames
- fourslash
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
370 files changed
+15654
-1223
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3288 | 3288 | | |
3289 | 3289 | | |
3290 | 3290 | | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
3291 | 3311 | | |
3292 | 3312 | | |
3293 | 3313 | | |
| |||
6338 | 6358 | | |
6339 | 6359 | | |
6340 | 6360 | | |
6341 | | - | |
6342 | | - | |
6343 | | - | |
6344 | | - | |
6345 | | - | |
6346 | | - | |
6347 | | - | |
6348 | | - | |
6349 | 6361 | | |
6350 | 6362 | | |
6351 | 6363 | | |
| |||
6389 | 6401 | | |
6390 | 6402 | | |
6391 | 6403 | | |
| 6404 | + | |
| 6405 | + | |
| 6406 | + | |
| 6407 | + | |
6392 | 6408 | | |
6393 | 6409 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
| 371 | + | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
374 | 381 | | |
375 | 382 | | |
376 | | - | |
| 383 | + | |
377 | 384 | | |
378 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
379 | 393 | | |
| 394 | + | |
380 | 395 | | |
381 | 396 | | |
382 | 397 | | |
| |||
803 | 818 | | |
804 | 819 | | |
805 | 820 | | |
806 | | - | |
807 | 821 | | |
808 | 822 | | |
809 | 823 | | |
| |||
816 | 830 | | |
817 | 831 | | |
818 | 832 | | |
819 | | - | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
820 | 881 | | |
821 | 882 | | |
822 | 883 | | |
823 | 884 | | |
824 | 885 | | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
830 | 890 | | |
831 | 891 | | |
832 | 892 | | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
833 | 944 | | |
834 | 945 | | |
835 | 946 | | |
836 | 947 | | |
837 | 948 | | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
844 | 954 | | |
845 | 955 | | |
846 | 956 | | |
| |||
897 | 1007 | | |
898 | 1008 | | |
899 | 1009 | | |
900 | | - | |
| 1010 | + | |
0 commit comments