feat(core): stronger types, iOS fixes, and opt-in hooks for cli extensions by NathanWalker · Pull Request #11682 · NativeScript/NativeScript
Repository navigation
feat(core): stronger types, iOS fixes, and opt-in hooks for cli extensions - #11682
Merged
NathanWalker merged 6 commits into main from feat/core-stronger-types-and-hooks Nov 28, 2026
Merged
feat(core): stronger types, iOS fixes, and opt-in hooks for cli extensions #11682 NathanWalker merged 6 commits into main from feat/core-stronger-types-and-hooks
Conversation
NathanWalker commented Nov 25, 2026 · edited Loading
Copy link Copy Markdown
Contributor
What is the current behavior?
- Two vendored pure-JavaScript files that
@nativescript/coreimports directly (fetch/index.mjsandjs-libs/easysax/easysax.js) only have minimal 4-line and 8-line hand-written.d.mts/.d.tsstubs, so their implementations are unchecked by TypeScript. - Several core APIs declare types narrower or different from what actually runs at runtime (e.g.,
resolveModuleNamereturningnull, CSS shorthand converters probed withunsetValue,PropertyBagstoring converted longhand values, iOSCGPathhelpers typed asUIBezierPath,_getFragmentManagerwalkingViewBaseancestors,NSURLSessionConfigurationcreated eagerly at module load). - Four deprecated iOS APIs (
dispatch_get_current_queue,base64Encoding,presentModalViewControllerAnimated,UITextAttributeTextColor) and four runtime bugs (TouchGestureEventData.getX/getYreadingcontentOffseton non-UIScrollView,generateShadowLayerPathsmissing its box-shadow argument inanimation.ios,Background.equalscomparing backgrounds instead of gradient images,text-base.iosclearingshadowColorwith aUIColorinstead ofCGColor) remain in core. ui/builderandui/core/bindablehave no opt-in registry hooks for ahead-of-time compiled XML page factories or binding expressions, andIConfigPlatformis not exported fromconfig.interface.ts/index.d.tsfor external CLI plugins to augmentNativeScriptConfigcleanly.
What is the new behavior?
refactor(core): convert vendored fetch and easysax to strict TypeScript(6 files, +1,270 −1,331 = net −61 lines , zero behavior change )- Replaces
fetch/index.mjs(+.d.mts) withfetch/index.tsandjs-libs/easysax/easysax.js(+.d.ts) witheasysax.ts(MIT notices andLICENSEfiles preserved). - Pure strong-typing upgrade with no behavioral change under V8/JSC: verified against the original JS implementations over 216 fetch scenarios (headers, requests/responses of every body type, double-reads, status codes, network errors, aborts) and 49,724 easysax inputs with identical outputs/event logs. The only two micro-differences:
fetch'sbodyUsedis now an own property per body, andeasysax'sParserEvent.prefix/namespaceare typedstring | undefined, matching what they already hold at runtime.
- Replaces
fix(core): types that say what runs(9 files, +80 −57)- Accurate TypeScript types across
module-name-resolver,ui/core/properties,ui/styling/style,ui/styling/background.ios,ui/core/view/index.android,utils/native-helper-for-android,xhr, andhttp/http-request-internal/index.ios(also defersNSURLSessionConfigurationcreation to first request instead of module load, saving a few ms at iOS app launch).
- Accurate TypeScript types across
fix(core): deprecated iOS APIs and four bugs found by strict typing(8 files, +22 −20)- Replaces the four deprecated iOS APIs and fixes the four bugs above (all improvements under V8/JSC as well; note
animation/index.ios.tsoverlaps with fix(ios): pass box shadow to shadow paths during size animations #11680 ).
- Replaces the four deprecated iOS APIs and fixes the four bugs above (all improvements under V8/JSC as well; note
feat(core): opt-in hooks for compiled XML pages and bindings(6 files, +133 −38)- Adds inert opt-in registries
registerPageFactory(ui/builder) andregisterCompiledBinding(ui/builder/binding-builder,ui/core/bindable). Nothing in core registers anything, so under V8 and JavaScriptCore both registries remain empty andBuilder/Bindingbehave identically to today.
- Adds inert opt-in registries
feat(core): export IConfigPlatform for plugin config augmentation(2 files, +2 −2)- Exports
IConfigPlatformalongsideNativeScriptConfiginconfig/config.interface.tsandindex.d.tsso external CLI plugins can cleanly augmentNativeScriptConfigand per-platformios/androidconfig via TypeScript module augmentation without adding plugin-specific options to core. Types only.
- Exports
refactor(core): convert vendored fetch and easysax to strict TypeScript
33f6682
Stronger type checking for two vendored JavaScript libraries core already imports directly (`globals/index.ts` -> `fetch`, `xml/index.ts` -> `easysax`), with zero behavior change under V8/JSC (net -61 lines). - fetch/index.ts replaces fetch/index.mjs and its 4-line .d.mts: whatwg-fetch as typed classes over core's XMLHttpRequest, Blob, FileReader and FormData (MIT notice kept; LICENSE in the folder). Verified against the original over 216 scenarios (headers, requests and responses of every body type, each body read twice, each status, network errors, aborts) with identical results. One micro-difference: `bodyUsed` is each body's own property. globals imports it without the extension. - js-libs/easysax/easysax.ts replaces easysax.js and its 8-line .d.ts as a typed class with identical parsing, events, entities, namespaces and errors, verified against the original over 49,724 inputs and parser setups with identical event logs. xml/index.ts imports it without the extension, and ParserEvent's prefix and namespace are typed `string | undefined`, matching what they already hold at runtime for an element without a prefix.
fix(core): types that say what runs
5f2f9a9
The compiler type-checks core strictly and spells every type in Swift or Kotlin, so a declared type must hold every value the code gives it. No behaviour change, except where noted. - module-name-resolver: resolveModuleName returns `string | null` (null when nothing resolves, which callers already test for). - properties: shorthand converters take any value (getCssShorthandLonghands probes them with unsetValue); the style-symbol map holds CSS animation properties as well as CSS properties. - style: PropertyBag holds converted longhand values as well as strings. - background.ios: the clip-path helpers return a CGPath (UIBezierPath.CGPath), not the UIBezierPath they were declared to. - view.android: _getFragmentManager walks ViewBase ancestors (a TabViewItem is one, and has fragments of its own) and reads _dialogFragment only on a View. - native-helper-for-android: dismissSoftInput's modal owner is read untyped. - xhr: XMLHttpRequestResponseType is a plain object (what the namespace compiled to); Blob's internal accessor is a named class. - http-request-internal.ios: sessions are typed NSURLSession; the user agent and the session configuration are made on the first request instead of when the module loads (creating an NSURLSessionConfiguration costs a few milliseconds of every app's launch).
fix(core): deprecated iOS APIs and four bugs found by strict typing
0930972
Compiling core to Swift rejects deprecated APIs and calls whose arguments do not match; each of these is a fix under the JavaScript runtime too. - image-source.ios: dispatch_get_current_queue (deprecated) gives way to the caller's operation queue, else main; base64Encoding to base64EncodedStringWithOptions(0). - dialogs.ios: presentModalViewControllerAnimated to presentViewControllerAnimatedCompletion. - tab-view.ios: UITextAttributeTextColor to NSForegroundColorAttributeName. - gestures.ios: TouchGestureEventData.getX/getY read contentOffset only from a UIScrollView (other views have none). - animation.ios: generateShadowLayerPaths takes the box shadow its layer draws; the animation called it without one (background.d.ts declares the parameter). - background-common: Background.equals compared the backgrounds, never gradients, instead of their images: gradient images now compare by value. - text-base.ios: clearing a text shadow sets a CGColor, not a UIColor, as the layer's shadowColor.
feat(core): opt-in hooks for compiled XML pages and bindings
5c5da05
Two registries a compiled build fills; nothing in core registers anything, so under V8 and JavaScriptCore both stay empty and the Builder behaves as before. - Builder: registerPageFactory(xmlModule, factory, codeModule?, codeExports?) registers a function that builds an XML file's view tree instead of parsing it, and optionally the code-behind's exports, which the Builder then takes instead of loading the module. The module name resolver still picks the file, so qualified variants (.ios.xml, .land.xml) keep their own factories. - Bindings: registerCompiledBinding(key, binding) registers an expression compiled ahead of time for the attribute at `file:line:column:attribute`; BindingOptions.compiled carries it, and Binding evaluates its closures in place of parsing the expression. The ComponentParser passes each element's key down (xmlModule, its start-tag position). - The component builder holds whatever element it creates (ViewBase: an ActionItem, a Span), and a dotted attribute sets a member of any object, as the code already did; the types say so now. - CompiledBinding is exported from ui.
feat(core): export IConfigPlatform for plugin config augmentation
783f90d
Export `IConfigPlatform` alongside `NativeScriptConfig` from `config.interface.ts` and `index.d.ts` so external CLI plugins (such as `@nstudio/nativescript-compiler`) can cleanly augment `NativeScriptConfig` and per-platform `ios`/`android` config via TypeScript module augmentation without adding plugin-specific options to core. Types only.
nx-cloud
Bot
commented
Nov 25, 2026
·
edited
Loading
Copy link Copy Markdown
|
View your CI Pipeline Execution ↗ for commit 6a1f00f
💡 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 |
pkg-pr-new
Bot
commented
Nov 25, 2026
·
edited
Loading
Copy link Copy Markdown
commit: |
Merge branch 'main' into feat/core-stronger-types-and-hooks
6a1f00f
NathanWalker
merged commit adbe443
into
main
Nov 28, 2026
13 checks passed
NathanWalker
deleted the
feat/core-stronger-types-and-hooks
branch
November 28, 2026 01:25
NathanWalker
mentioned this pull request
Nov 28, 2026
feat(core): let style converters preserve CSS math
#11668
Open
3 tasks done
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment