Title: docs: drop `return global.__native(this)` from Android subclass examples by edusperoni · Pull Request #206 · NativeScript/docs · GitHub
Open Graph Title: docs: drop `return global.__native(this)` from Android subclass examples by edusperoni · Pull Request #206 · NativeScript/docs
X Title: docs: drop `return global.__native(this)` from Android subclass examples by edusperoni · Pull Request #206 · NativeScript/docs
Description: The Android subclassing examples end their TypeScript constructors with return global.__native(this), and the agent guidance (assets/agentic/NATIVESCRIPT.md) tells coding agents to do the same. With TypeScript 2.0 and newer this call does nothing. Why it's a no-op When a TypeScript-compiled constructor calls a native base class's call/apply, the Android runtime marks the JS this with __container__ and returns the real native instance. __native(x) only unwraps objects that carry __container__. TypeScript < 2.0 emitted _super.call(this); return __native(this);, so this was the container and the call was needed. TypeScript 2.0+ emits var _this = _super.call(this) || this; ... return global.__native(_this);. _this is already the native instance, which never has __container__, so __native(_this) returns it unchanged. Every current NativeScript project compiles with TypeScript 2.0+, so a constructor only needs super(...), and can be left out if it does nothing else. The runtime still defines global.__native for backward compatibility (internal/ts_helpers.js in the Android runtime), so existing code that calls it keeps working. This only simplifies the docs; nothing breaks. Changes content/guide/extending-classes-and-implementing-interfaces-android.md: removed the call and its "necessary when extending TypeScript constructors" comments from the four TypeScript examples. Removed constructors that only called super(). Added a short tip saying the call isn't needed with TypeScript 2.0+ and that existing calls are harmless. content/guide/android-marshalling.md: removed the super() + __native constructors from the two MyVersatileCopyWriter examples. content/public/assets/agentic/NATIVESCRIPT.md: removed the constructor from the MyButton example and added an explicit instruction not to add return global.__native(this), since agents have likely seen the old pattern elsewhere. Verification npm run build (vitepress) succeeds, and the new tip renders. prettier --check and textlint find nothing new in the changed files. npm run lint:format already fails on main because of two unrelated files (content/configuration/vite.md, vite-framework-flavors.md), and NATIVESCRIPT.md was already unformatted before this change. A second commit runs prettier on content/configuration/vite.md and vite-framework-flavors.md. They were unformatted on main, which made the lint:format step (and so the build check) fail on every PR. It changes formatting only.
Open Graph Description: The Android subclassing examples end their TypeScript constructors with return global.__native(this), and the agent guidance (assets/agentic/NATIVESCRIPT.md) tells coding agents to do the same. Wit...
X Description: The Android subclassing examples end their TypeScript constructors with return global.__native(this), and the agent guidance (assets/agentic/NATIVESCRIPT.md) tells coding agents to do the same. Wit...
Opengraph URL: https://github.com/NativeScript/docs/pull/206
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:cc362742-308a-b63d-8dcc-1ca7cc33e6dd |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 85EC:2E3FEE:15CC71B:1BA3723:6B0130F9 |
| html-safe-nonce | 88c2ebb70e0a6f4d396b25a313aea13a679a8c9c1ed1654a8d25e98aeb5e5d51 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NUVDOjJFM0ZFRToxNUNDNzFCOjFCQTM3MjM6NkIwMTMwRjkiLCJ2aXNpdG9yX2lkIjoiNjk4ODM1MDg1ODMwMzk3NTY3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 726c69dc2051ab666e2a832f0b02349236805c7c3015cf152b88cb468d2ae64b |
| hovercard-subject-tag | pull_request:5253698794 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/docs/pull/206/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | The Android subclassing examples end their TypeScript constructors with return global.__native(this), and the agent guidance (assets/agentic/NATIVESCRIPT.md) tells coding agents to do the same. Wit... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/docs git https://github.com/NativeScript/docs.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 567462026 |
| octolytics-dimension-repository_nwo | NativeScript/docs |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 567462026 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/docs |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width