swiftwasm / swiftwasm/JavaScriptKit
[BridgeJS] Support union types
Nessuno ha ancora preso questa issue.
- Lingua principale
- Swift
- Stelle
- 986
- Fork
- 76
- Merge medio
- 21h 11m
- PR unite (30g)
- 4
Descrizione
Union types (other than rawvalue which are already done) should be supported. The best way to do this is unclear to me so this issue functions as a discussion point.
Example:
export type Foo = { foo: string }
export type Bar = { bar: string }
export type Example = Foo | Bar
export function example(): Example
Could maybe generate:
@JSClass struct Foo {
@JSGetter var foo: String
@JSSetter func setFoo(_ value: String) throws(JSException)
}
@JSClass struct Bar {
@JSGetter var bar: String
@JSSetter func setBar(_ value: String) throws(JSException)
}
@JSClass enum Example {
case foo(Foo)
case bar(Bar)
}
@JSFunction func example() throws(JSException) -> Example
Note that ts unions can change dynamically eg if I set foo to null and bar to a string, the type changes from Foo to Bar, so idk if that works with an enum like this in Swift.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Non viene indicato alcun file o test. Inizia individuando il supporto esistente per rawvalue a cui si fa riferimento nell’issue e analizzando come le union TypeScript mostrate vengono mappate su Swift; chiarisci come dovrebbero essere rappresentati i cambiamenti a runtime tra le varianti. Il lavoro è completato quando la union Example e la firma example() interoperano correttamente, inclusi i cambiamenti dinamici tra Foo e Bar.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, swift, typescript
- Ambito
- api
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Tranquilla
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100