NativeScript / NativeScript/android
Consider support for extending native generic classes and providing generic arguments
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C++
- Sterne
- 563
- Forks
- 144
- Ø Merge
- 10 Std. 46 Min.
- Gemergte PRs (30 T.)
- 14
Beschreibung
Currently, there is no way to implement for example java.util.List<T> and provide information what would be the type T. When extending such class/interface from TypeScript the following way:
@Interfaces([java.util.List])
class JSList implements java.util.List {
}
the static binding generator prior 5.3.1 would generate a proxy class with a similar signature:
public class JSList implements java.util.List
The introduced changes of the SBG in 5.3.1 generate public class JSList implements java.util.List<Object> having resolved the generic parameter T using its erasure (in this case java.lang.Object) as if it's a raw class inheritance.
With the changes of the SBG in 5.3.1, there is a way to feed it information about what would be the generic parameters when extending, however this would require some changes in the syntax of extending/implementing native classes:
@Native
class JSList implements java.util.List<java.lang.Integer>{
}
The above shown syntax would be possible with some changes in the webpack plugin and the js_parser.js in the SBG.
In order to collect information about the generic arguments provided in the TS code there should be a custom transformer plugged into the webpack pipeline whose goal would be to lookup every TS node with a @Native decorator and preserve its extended class and implemented interfaces information somewhere. This could be stored by modifying the AST and creating internal decorators only for storage. Further, when the js_parser.js parses the JS code, it can look for the internal decorators and retrieve the information about the generics storing them for the SBG.
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 dem webpack-Plugin und js_parser.js, die im Issue beschrieben sind. Verfolge, wie @Native-Deklarationen sowie erweiterte oder implementierte Typen derzeit dargestellt werden, und ermittle anschließend, wie ein benutzerdefinierter Transformer generische Argumente für den Parser bewahren kann. Als abgeschlossen gilt die Änderung, wenn TypeScript wie java.util.List<java.lang.Integer> eine Binding mit diesem generischen Argument statt Object erzeugt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java, typescript, webpack
- Bereich
- build-system, mobile-dev, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100