facebook / facebook/flow

No way to describe a JSX intrinsic which accepts props of a given type

Aperta
#4,746 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
22.3k
Fork
1.9k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Thanks to `$JSXIntrinsics`, Flow knows the type of the props of each intrinsic. However, there appears to be no way to describe a JSX intrinsic which accepts props of a given type. That is, today I have to write:

```jsx
const SideBySide = (
First: React.ElementType,
Second: React.ElementType,
props: {}
) =>




;
```

which does not validate that `First` and `Second` take the given props. It would be better to be able to write:

```jsx
const SideBySide = (
First: React.ElementType

,
Second: React.ElementType

,
props: P
) =>




;
```

You *can* say:

```jsx
const SideBySide = (
First: React.ComponentType

,
Second: React.ComponentType

,
props: P
) =>




;
```

but this limits `First` and `Second` to being composite component types, when there's no (application) reason not to allow them to be intrinsic types.

It's possible that there's some kind of type wizardry which can implement what I'm describing, but I haven't been able to come up with it.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.