Repository navigation
refactor(android): remove no-op global.__native(this) constructor returns - #11652
Conversation
…urns __native only unwraps the placeholder object of the pre-TypeScript 2.0 constructor emit (super(); return __native(this)). With the current emit the constructor already holds the native instance from var _this = _super.call(this) || this, so __native returns it unchanged.
|
View your CI Pipeline Execution ↗ for commit 25395c6
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
NathanWalker
left a comment
There was a problem hiding this comment.
Clean removal across all 33 @NativeClass constructors (with the 34th in SnapshotViewGroup removed in #11651), while keeping global.__native intact and leaving layout-helper.android.ts and the bundler specs covering the legacy return pattern. Note that a few of these constructors (Button, ActionBar, SegmentedBar, TextBase, fragment.transitions) overlap with #11656–#11658 and #11662, so whichever lands second will just need a quick rebase on those lines.
PR Checklist
What is the current behavior?
34 native class constructors in
packages/coreend withreturn global.__native(this);.__native(the runtime'sts_helpers.js) only does something for the placeholder object of the pre-TypeScript 2.0 emit,_super.call(this); return __native(this);. With the current emit,var _this = _super.call(this) || thisalready holds the native instance. That instance never has__container__, so__nativereturns it unchanged.What is the new behavior?
Removes 33 of those constructor returns. The
global.__nativefunction itself is not touched, so third-party code that still calls it keeps working. NativeScript/docs#206 removes it from the docs.The 34th is in
ui/transition/page-transition.android.ts, insideSnapshotViewGroup, which #11651 deletes as unused.Static binding generator note: when a constructor body becomes only
super(...), the ES5 emit becomesreturn _super.call(this, ...) || this;. In core's build that is 6 classes:TNSAccessibilityDelegateImplSeekBarChangeListenerImplLruBitmapCacheDialogFragmentImplTabHostImplAnimationListenerImplThe Android SBG finds the class location in that shape since NativeScript/android#2101, which is merged and on the runtime's
nexttag. On 9.0–9.1.1 runtimes these classes are generated at runtime anyway (a naming bug #2101 also fixed), so nothing changes there. On runtimes older than 9.0, these 6 classes switch from prebuilt to runtime-generated.Split out of #11636.