microsoft / microsoft/TypeScript
Can't assign to partial of intersection with mapped type over generic
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 Search Terms
"mapped type", "mapped generic type", "intersection", "partial"
🕗 Version & Regression Information
Current version of Typescript, not sure if it's a regression
⏯ Playground Link
No response
💻 Code
Simple to reproduce:
type X = 'a' | 'b' | 'c'
const foo = <T extends X>() => {
const result: Partial<{d:number} & {[P in T]: boolean}> = {
// error: Type '{ d: number; }' is not assignable to type 'Partial<{ d: number; } & { [P in T]: boolean; }>'
d: 1
}
}
🙁 Actual behavior
I get an error
🙂 Expected behavior
I am able to use this type in general; I expect to be able to use a partial of it as well. The only thing I've found that satisfies the type is an empty object
Additional information about the issue
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem minimalen generischen TypeScript-Beispiel im Issue und reproduziere den Fehler mit dem aktuellen Compiler. Untersuche, wie der Type Checker Partial über einer Intersection behandelt, die einen mapped type enthält, und betrachte das Issue als erledigt, wenn das Beispiel d: 1 akzeptiert und dabei die generische Constraint beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100