microsoft / microsoft/TypeScript
Type bug: using mapped type (Partial) & this type & lookup type
Aperta
@ahejlsberg ci sta già lavorando.
Dal 6/2/2020.
Needs Investigation
Rescheduled
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.