How to extract structure from class?
- Lingua principale
- Rust
- Stelle
- 22.3k
- Fork
- 1.9k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Classes are nominally typed. How to extract structural interface from class?
What i imagine:
```js
//@flow
import React from 'react'
class P {
a: string;
b: string;
}
type IP = $Structure
function A(
props: IP
) {
return
}
May be some magic $Structure utility to create interface from class?
Why i need it: in runtime we can't use interface as reference, say in c# ISome is a reference to Some:
```c#
interface ISome {}
function a(a: ISome) {}
class Some {}
Bind().To();
```
But in js we can reference without decorators and string keys only by abstract classes / functions. In first example i want to use abstract class instead of interface as property type. But flow does not permit to do this.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.