How to extract structure from class?
- Vorherrschende Sprache
- Rust
- Sterne
- 22.3k
- Forks
- 1.9k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.