Skip to content

fix(types): nullable blocks as (() => T) | null; declare NativeObject.extend - #84

Merged
ammarahm-ed merged 1 commit into
android-react-nativefrom
fix/types-nullable-blocks-extend
Oct 25, 2026
Merged

ammarahm-ed merged 1 commit into
android-react-nativefrom
fix/types-nullable-blocks-extend

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

Split out of #77 (item 9 of the "NativeScript bugs" list in ng-native/ng-native#931).

Summary

  • Nullable callbacks. The TS emitter wrote nullable blocks as () => void | null, which TypeScript reads as a function returning void | null. Passing null, for example presentViewControllerAnimatedCompletion(vc, true, null), was a type error.
    - completion: () => void | null
    + completion: (() => void) | null
  • NativeObject.extend. extend() works on every native class at runtime but wasn't declared. It is now declared with objc.ExtendOptions. Overridden methods are typed from the class, and protocol and exposed methods are accepted.
  • nativescript-rn configure. The next-steps hint said Android typings were generated on demand with -PnsGenerateTypings=true. nativescript.gradle generates them by default, so the hint now says that.

Evidence

tsc --strict against freshly generated iOS 27.1 declarations (tested in #77, same change).

  • Before: presentViewControllerAnimatedCompletion(vc, true, null) and UIView.extend({...}) fail to type-check.
  • After: both pass.

Merge Danger

Door: two-way

Blast Radius: generated .d.ts files

Regenerated declarations change shape for every nullable block parameter. Types become more permissive, never stricter.

….extend

- The emitter wrote nullable callbacks as `() => void | null`, which
  TypeScript reads as a function returning void | null, so passing null
  (e.g. presentViewControllerAnimatedCompletion's completion) was a type
  error. They are parenthesized now.
- extend() works on every native class at runtime but was undeclared.
  NativeObject.extend types overridden methods from the class, accepts
  protocol/exposed methods, and takes objc.ExtendOptions.
- nativescript-rn configure no longer says Android typings are generated
  on demand: nativescript.gradle generates them unless
  -PnsGenerateTypings=false.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 18ad085c-fcae-4ff6-bb88-23a2e856927b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ammarahm-ed
ammarahm-ed merged commit 95739d3 into android-react-native Oct 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants