ROBLOX TS: Attempted to assign method where non-method was expected

So I’ve recently tried to test ROBLOX TS for a game, and i’m trying to use Fusion “On Event”, but its really poorly documented, and when I try to run my code, I get the error in the title.

My code:

export default function (Props: { text: Fusion.Value<string>; onPressed(): never }) {
	const STATE = {
		BACKGROUND_COLOR: Fusion.Value(ThemeProvider.colorScheme.primary),
	};

	const Component = Fusion.New("TextButton")({
		Name: "Button",
		BackgroundColor3: Fusion.Tween(STATE.BACKGROUND_COLOR, new TweenInfo(0.15)),
		Text: Props.text,
		TextColor3: ThemeProvider.colorScheme.onPrimary,
		FontFace: ThemeProvider.textTheme.title.large.font,
		TextSize: ThemeProvider.textTheme.title.large.fontSize,
		AutomaticSize: Enum.AutomaticSize.X,
		Size: new UDim2(0, 0, 0, 35),
		____FusionChildren: [
			Fusion.New("UICorner")({
				CornerRadius: new UDim(1, 0),
			}),
			Fusion.New("UIPadding")({
				PaddingLeft: new UDim(0, 35),
				PaddingRight: new UDim(0, 35),
			}),
		],
		____FusionOnEventSymbolMouseEnter() {
			STATE.BACKGROUND_COLOR.set(ThemeProvider.colorScheme.primary.Lerp(ThemeProvider.colorScheme.surface, 0.15));
		},
		____FusionOnEventSymbolMouseLeave() {
			STATE.BACKGROUND_COLOR.set(ThemeProvider.colorScheme.primary);
		},
		____FusionOnEventSymbolMouseButton1Down() {
			STATE.BACKGROUND_COLOR.set(ThemeProvider.colorScheme.inversePrimary);
		},
		____FusionOnEventSymbolMouseButton1Up() {
			STATE.BACKGROUND_COLOR.set(ThemeProvider.colorScheme.primary.Lerp(ThemeProvider.colorScheme.surface, 0.15));
		},
	});

	return Component;
}

The error:

error TS roblox-ts: Attempted to assign method where non-method was expected.

27   ____FusionOnEventSymbolMouseEnter() {
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28    STATE.BACKGROUND_COLOR.set(ThemeProvider.colorScheme.primary.Lerp(ThemeProvider.colorScheme.surface, 0.15));
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29   },
   ~~~

In short:
this error indicates that your class implements interface in which this method “____FusionOnEventSymbolMouseEnter” was initialized as property or other type.
For example:

interface IImplementMe {
  ____FusionOnEventSymbolMouseEnter: () => void; // defined as property
}

But you need it like this:

interface IImplementMe {
  ____FusionOnEventSymbolMouseEnter(): void; // defined as method
}
1 Like

the solution is to do

MethodName : () : returnType => {

} 

instead of

MethodName() : returnType {

}