Intersecting types based on Generic types
Offen
- Vorherrschende Sprache
- Rust
- Sterne
- 22.3k
- Forks
- 1.9k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Lets say I have an object type that represents the template of other more specific types. How does one define the more specific type so that the following usecase does not fail?
Here's a failing attempt:
```js
type Data = {
loading: boolean,
error: string,
fetch: (options: {
update: (prevResult: T1, moreData: { moreResult: T1, moreVar: Object }) => Object
}) => void
}
type SpecificData = Data & {
items: Array
}
const f = (data: SpecificData) => ({
data,
loadMore: () => {
data.fetch({
update: (prevResult, { moreResult, moreVar }) => ({
items: [...prevResult.items, ...moreResult.items]
})
})
}
})
```
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.