-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
infer on setter argument gives unknown #47146
Comments
π² The "fix" here is to make this a syntax error, at least for now. |
@RyanCavanaugh i try to get setter type, is there any solution ? |
TypeScript doesn't really distinguish between accessors and regular properties at the type level, so |
@RyanCavanaugh Should TS throw the following error? A computed property name must be of type 'string', 'number', 'symbol', or 'any'. |
The error should be that type Foo1<K extends string> = {[P in K]: number};
// Should error
type Foo2<K extends string> = {get [P in K](): number};
// ^^^^^^^^^^^^
// Cannot combine property get/set with mapped type syntax
type A = Foo1<"prop">;
type B = Foo2<"prop">;
type AP = A["prop"];
type BP = 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. will this feature be added in future releases? |
The future's a long time, but no this is not part of the scheduled roadmap |
Wow, this is super broken... type OH_NO = {
get [K in WAT](): string
}; |
@Galphimbl You might want to follow #43729. |
Bug Report
π Search Terms
setter, getter, infer
π Version & Regression Information
β― Playground Link
Playground Link
π» Code
π Actual behavior
Hovering on
setter
gives youπ Expected behavior
Hovering on
setter
gives youThe text was updated successfully, but these errors were encountered: