NativeScript / NativeScript/ios
Question on declarations generation
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 150
- Forks
- 43
- Ø Merge
- 3 T. 10 Std.
- Gemergte PRs (30 T.)
- 22
Beschreibung
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:
@protocol Option
-(NSString *) optionId;
-(NSString *) type;
@end
typedef NSObject<Option> Option;
@protocol Info
-(NSArray<NSObject<Option> *> *) getOptions;
@end
typedef NSObject<Info> Info;
the (shortened) declarations in ios.d.ts are
interface Option {
optionId(): string;
type(): string;
}
declare var Option: {
prototype: Option;
};
interface Info {
getOptions(): NSArray<NSObject>;
}
declare var Info: {
prototype: Info;
};
You may notice that the returned Array of getOptions is typed with NSObject instead of Option, 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:
- Are our input (the header files) missing something or do they have to be different soemhow to get beter outcomes?
- If not would it be possible to patch the generator?
- Am i totally wrong here?
Cheers and again thanks for your work.
legion
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit metadata-generator/src/TypeScript/DefinitionWriter.cpp um Zeile 862 und vergleiche dessen Typauswertung mit den Objective-C-Headerdeklarationen und der hier gezeigten generierten ios.d.ts. Ermittle, ob die Eingabe-Header geändert werden müssen oder ob der Generator Protokolltypen verliert; die Fertigstellung ist durch eine klare Diagnose und korrekt beibehaltene Argument- und Rückgabetypen statt NSObject gekennzeichnet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp, objective-c, typescript
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 30/100