You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error should be that get/set can't be combined with mapped types.
typeFoo1<Kextendsstring>={[PinK]: number};// Should errortypeFoo2<Kextendsstring>={get[PinK](): number};// ^^^^^^^^^^^^// Cannot combine property get/set with mapped type syntaxtypeA=Foo1<"prop">;typeB=Foo2<"prop">;typeAP=A["prop"];typeBP=B["prop"];// ^ never worked anyway
I tried to work with the changes added in release 4.3 ("Separate Write Types on Properties"), but there is no way to select only those setter keys that accept a specific data type.
Activity
RyanCavanaugh commentedon Dec 14, 2021
π²
set [P in K](v: U)was never supposed to be allowed syntax. I'm honestly shocked this doesn't crash; the syntax doesn't really work at all.The "fix" here is to make this a syntax error, at least for now.
Galphimbl commentedon Dec 14, 2021
Ryan Cavanaugh (@RyanCavanaugh) i try to get setter type, is there any solution ?
fatcerberus commentedon Dec 14, 2021
TypeScript doesn't really distinguish between accessors and regular properties at the type level, so
Test1['prop']is about the best you can do.a-tarasyuk commentedon Dec 14, 2021
Ryan Cavanaugh (@RyanCavanaugh) Should TS throw the following error?
RyanCavanaugh commentedon Dec 14, 2021
The error should be that
get/setcan't be combined with mapped types.Galphimbl commentedon Dec 14, 2021
I tried to work with the changes added in release 4.3 ("Separate Write Types on Properties"), but there is no way to select only those setter keys that accept a specific data type.
will this feature be added in future releases?
RyanCavanaugh commentedon Dec 15, 2021
The future's a long time, but no this is not part of the scheduled roadmap
RyanCavanaugh commentedon Dec 15, 2021
Wow, this is super broken...
Make it fail
MartinJohns commentedon Dec 16, 2021
Oleksandr Tkachov (@Galphimbl) You might want to follow #43729.
Correctly check computed property names in type-space get/set accessoβ¦