Skip to content
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

TS complains about @override #3820

Open
IanBellomy opened this issue Jan 24, 2024 · 2 comments
Open

TS complains about @override #3820

IanBellomy opened this issue Jan 24, 2024 · 2 comments
Labels

Comments

@IanBellomy
Copy link

Moving to finalized decorators and getting a TS complaint about @override.

Using Typescript 5.3.3, Mobx 6.12 with "experimentalDecorators":false.

Screenshot 2024-01-24 at 9 14 29 AM
Unable to resolve signature of method decorator when called as an expression.
  No overload matches this call.
    Overload 1 of 2, '(target: Object, propertyKey: string | symbol): void', gave the following error.
      Argument of type 'ClassGetterDecoratorContext<Sub, number> & { name: "val"; private: false; static: false; }' is not assignable to parameter of type 'string | symbol'.
    Overload 2 of 2, '(value: any, context: ClassMethodDecoratorContext<any, any>): any', gave the following error.
      Argument of type 'ClassGetterDecoratorContext<Sub, number> & { name: "val"; private: false; static: false; }' is not assignable to parameter of type 'ClassMethodDecoratorContext<any, any>'.
        Types of property 'kind' are incompatible.
          Type '"getter"' is not assignable to type '"method"'.ts(1241)

override's type seems to include ClassMethodDecorator though not ClassGetterDecorator but I haven't found anything in docs about no longer using @override for subclass getters, so I'm not sure if this typing is intentional and if so what preferred approach is for handling subclass overrides sans makeObservable.

Copyable Code:

import { computed, override } from "mobx"

class Main{
	@computed
	get val(){
		return 1
	}
}

class Sub extends Main{
	@override 
	override get val(){
		return 1
	}
}
@smiley-uriux
Copy link

Hitting this also, @IanBellomy did you find a workaround?

@IanBellomy
Copy link
Author

Don't believe so — IIRC I tabled the project's switch to finalized decorators until this and other decorator related issues in the pipeline got ironed out. Haven't circled back yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants