Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion metadata-generator/src/TSEmitter/TypeSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ std::string TSFile::typeToString(const TypeSpec& type, bool isStatic, bool isRet
result += ") => ";
result += typeToString(*type.callbackReturn, false, true);
if (type.isNullable) {
result += " | null";
// `() => T | null` would make the return type nullable instead.
result = "(" + result + ") | null";
}
break;
}
Expand Down
34 changes: 34 additions & 0 deletions packages/objc-node-api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ declare global {

class NativeObject implements interop.PointerObject {
readonly __brand__: interop.PointerObject["__brand__"];

/**
* Registers an Objective-C subclass of this class. Functions in `methods`
* override the same-named members of this class and of
* `options.protocols`; other names are only callable from Objective-C
* when listed in `options.exposedMethods`. The returned class cannot
* itself be extended.
*/
static extend<
// deno-lint-ignore no-explicit-any
This extends abstract new (...args: any) => any,
// Inferred rather than annotated so that names absent from the class
// (protocol and exposed methods) are not excess properties. `& object`
// keeps literals sharing no name with the class from failing the weak
// type check against the all-optional Partial.
Methods extends Partial<InstanceType<This>> & object,
>(
this: This,
methods: Methods & ThisType<InstanceType<This> & Methods>,
options?: objc.ExtendOptions,
): This;
}

namespace objc {
Expand All @@ -25,6 +46,19 @@ declare global {
ptr: interop.Pointer,
size: number,
): ArrayBuffer;

export interface ExposedMethod {
returns?: unknown;
params?: unknown[];
}

export interface ExtendOptions {
/** Objective-C class name; a numeric suffix is added if it is taken. */
name?: string;
protocols?: unknown[];
/** Keyed by method name in `methods`. */
exposedMethods?: Record<string, ExposedMethod>;
}
}

namespace interop {
Expand Down
5 changes: 3 additions & 2 deletions packages/react-native/cli/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ function printNextSteps() {
console.log(' iOS : cd ios && RCT_NEW_ARCH_ENABLED=1 USE_HERMES=1 pod install');
console.log(' Android : npx react-native run-android');
console.log('');
console.log(' Android typings are generated on demand:');
console.log(' cd android && ./gradlew generateNativeScriptTypingsDebug -PnsGenerateTypings=true');
console.log(' Android typings are written to types/android/ on the first build');
console.log(' (opt out with -PnsGenerateTypings=false). To generate them on their own:');
console.log(' cd android && ./gradlew generateNativeScriptTypingsDebug');
}

function configure(argv = process.argv.slice(2)) {
Expand Down
Loading