microsoft / microsoft/TypeScript
Type bug: using mapped type (Partial) & this type & lookup type
Offen
@ahejlsberg arbeitet bereits daran.
Seit 06.2.2020.
Needs Investigation
Rescheduled
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
TypeScript Version: nightly
Search Terms: mapped type, Partial, this, lookup type
Code
class A {
state = { foo: "foo", bar: 42 };
something(): Partial<A["state"]> {
return { foo: "changed" }; // works
}
}
class B {
state = { foo: "foo", bar: 42 };
something(): Partial<this["state"]> {
return { foo: "changed" }; // fails
}
}
class C {
state = { foo: "foo", bar: 42 };
something(): Partial<this["state"]> {
return { foo: "changed", bar: 123 }; // works
}
}
Expected behavior:
Should type check.
Actual behavior:
Type '{ foo: "changed"; }' is not assignable to type 'Partial<this["state"]>'.(2322)
Playground Link: Example
Related Issues: Tried searching for Partial this, did not find anything related.
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.
Bewertung
Dieses Issue wurde noch nicht bewertet.