Skip to content

Commit 99824ec

Browse files
authored
fix: optional error parameter for NSError out parameters (#310)
Add optional error parameter for methods with NSError**
1 parent 09564aa commit 99824ec

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

metadata-generator/src/TypeScript/DefinitionWriter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,17 @@ std::string DefinitionWriter::writeMethod(MethodMeta* meta, BaseClassMeta* owner
611611

612612
}
613613

614+
// If the method has an NSError** last parameter, emit an optional error parameter
615+
if (meta->getFlags(::Meta::MetaFlags::MethodHasErrorOutParameter)) {
616+
// If there were already parameters emitted, ensure we add a comma
617+
if (lastParamIndex > 1) {
618+
output << ", ";
619+
}
620+
// Emit a typed optional parameter for the NSError** out parameter.
621+
// We use the conventional name 'error' and the interop.Reference wrapper expected by NativeScript.
622+
output << "error?: interop.Reference<NSError>";
623+
}
624+
614625
output << "): ";
615626
if (skipGenerics) {
616627
output << "any;";

0 commit comments

Comments
 (0)