-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question on declarations generation #205
Comments
I don't know the answer, we'll have to look a bit deeper and understand what's going on - I would expect the return type to be |
Shouldn't the generated declaration have Option extend NSObject in some way? Theoretically it returns NSObjects which is correct, but it's also Option. I might be wrong though |
Yeah, I guess it should generate something like interface Option extends NSObject {
optionId(): string;
type(): string;
}
declare var Option: {
prototype: Option;
};
interface Info {
getOptions(): NSArray<Option>;
}
declare var Info: {
prototype: Info;
}; |
@rigor789 I'm not sure about it, but the runtime sometimes can do some magic when converting struct types where you can pass https://docs.nativescript.org/advanced-concepts.html#struct-types Maybe this is the correct output:
This way you can use Option (and the magic) in a transparent way, but the return is |
Hello and thanks for your work.
I have a question regarding the generation of ios typescript declarations hoping to be in the right place.
We're using a robovm based toolchain to build a native library for iOS from Java-code. This toolchain emits header files in the following (shortened) form:
the (shortened) declarations in ios.d.ts are
You may notice that the returned Array of
getOptions
is typed withNSObject
instead ofOption
, which is the reason for this writing.In fact are all argument- and return- types of functions which are defined by our headers typed with
NSObject
instead of the type which it should be.After digging a while i understand that the types are evaluated in that function
https://github.com/NativeScript/ios/blob/main/metadata-generator/src/TypeScript/DefinitionWriter.cpp#L862
which might be wrong since it's been a while that i read some cpp code.
I assume that this codes falls back to NSObject if it cannot determine the correct type.
Note, that if i manually adjust the types in ios.d.ts everything works fine.
So basically my questions:
Cheers and again thanks for your work.
legion
The text was updated successfully, but these errors were encountered: