R
roblox-ts•2mo ago
Pizza

Can you create aliases for flamework decorators

I have this code here:
import { OnStart } from "@flamework/core";
import { Component } from "@flamework/components";
import { SharedComponent } from "@rbxts/shared-components-flamework";
import { getBounds } from "shared/types/Bounds";

interface Attributes {}

@StructureComponent()
export abstract class BaseStructure extends SharedComponent<{}, Attributes, Model> implements OnStart {
protected state = {};
protected structureBase: BasePart;

constructor() {
super();
const base = this.instance.WaitForChild("StructureBase");
assert(base && base.IsA("BasePart"), "StructureBase must be a BasePart");
this.structureBase = base;
}

onStart() {
print("structure:", this.instance.Name);
print("structure center:", this.structureBase.Position);
print("structure bounds:", getBounds(this.structureBase));
}
}

export function StructureComponent() {
return Component({
tag: "_structure",
predicate: (instance): instance is Model => {
if (!instance.IsA("Model")) return false;

const base = instance.FindFirstChild("StructureBase");
return base !== undefined && base.IsA("BasePart");
},
refreshAttributes: true,
});
}
import { OnStart } from "@flamework/core";
import { Component } from "@flamework/components";
import { SharedComponent } from "@rbxts/shared-components-flamework";
import { getBounds } from "shared/types/Bounds";

interface Attributes {}

@StructureComponent()
export abstract class BaseStructure extends SharedComponent<{}, Attributes, Model> implements OnStart {
protected state = {};
protected structureBase: BasePart;

constructor() {
super();
const base = this.instance.WaitForChild("StructureBase");
assert(base && base.IsA("BasePart"), "StructureBase must be a BasePart");
this.structureBase = base;
}

onStart() {
print("structure:", this.instance.Name);
print("structure center:", this.structureBase.Position);
print("structure bounds:", getBounds(this.structureBase));
}
}

export function StructureComponent() {
return Component({
tag: "_structure",
predicate: (instance): instance is Model => {
if (!instance.IsA("Model")) return false;

const base = instance.FindFirstChild("StructureBase");
return base !== undefined && base.IsA("BasePart");
},
refreshAttributes: true,
});
}
but im getting this error:
[4:43:53 PM] File change detected. Starting incremental compilation...

src/shared/components/BaseStructure.ts:28:90 - error TS2345: Argument of type '() => ((ctor: defined) => never) & { _flamework_Decorator: never; }' is not assignable to parameter of type '{ _flamework_Parameters: []; }'.

28 Reflect["decorate"](BaseStructure, "shared/components/BaseStructure@StructureComponent", StructureComponent, []);
~~~~~~~~~~~~~~~~~~

[4:43:54 PM] Found 1 error. Watching for file changes.
[4:43:53 PM] File change detected. Starting incremental compilation...

src/shared/components/BaseStructure.ts:28:90 - error TS2345: Argument of type '() => ((ctor: defined) => never) & { _flamework_Decorator: never; }' is not assignable to parameter of type '{ _flamework_Parameters: []; }'.

28 Reflect["decorate"](BaseStructure, "shared/components/BaseStructure@StructureComponent", StructureComponent, []);
~~~~~~~~~~~~~~~~~~

[4:43:54 PM] Found 1 error. Watching for file changes.
23 Replies
wAD
wAD•2mo ago
you don't need an alias just apply @Component() to the class you're extending it'll inherit
Pizza
PizzaOP•2mo ago
oh thanks i didn't know it inherited
wAD
wAD•2mo ago
ok it might actually not because it's a shared component @Tesmi can u check rq
Pizza
PizzaOP•2mo ago
oh
wAD
wAD•2mo ago
ive had issues with it not inheriting
Pizza
PizzaOP•2mo ago
:Sadge:
wAD
wAD•2mo ago
btw for now u can do
const StructureComponent = Component({
tag: "_structure",
predicate: (instance): instance is Model => {
if (!instance.IsA("Model")) return false;

const base = instance.FindFirstChild("StructureBase");
return base !== undefined && base.IsA("BasePart");
},
refreshAttributes: true,
});
const StructureComponent = Component({
tag: "_structure",
predicate: (instance): instance is Model => {
if (!instance.IsA("Model")) return false;

const base = instance.FindFirstChild("StructureBase");
return base !== undefined && base.IsA("BasePart");
},
refreshAttributes: true,
});
that would work @Pizza
Pizza
PizzaOP•2mo ago
ok
wAD
wAD•2mo ago
and then don't call it just do
@StructureComponent
class foo
@StructureComponent
class foo
Pizza
PizzaOP•2mo ago
src/shared/components/BaseStructure.ts:38:90 - error TS2345: Argument of type '((ctor: defined) => never) & { _flamework_Decorator: never; }' is not assignable to parameter of type '{ _flamework_Parameters: []; }'.

38 Reflect["decorate"](BaseStructure, "shared/components/BaseStructure@StructureComponent", StructureComponent, []);
~~~~~~~~~~~~~~~~~~

[4:48:47 PM] Found 1 error. Watching for file changes.
src/shared/components/BaseStructure.ts:38:90 - error TS2345: Argument of type '((ctor: defined) => never) & { _flamework_Decorator: never; }' is not assignable to parameter of type '{ _flamework_Parameters: []; }'.

38 Reflect["decorate"](BaseStructure, "shared/components/BaseStructure@StructureComponent", StructureComponent, []);
~~~~~~~~~~~~~~~~~~

[4:48:47 PM] Found 1 error. Watching for file changes.
uhhh it doesnt work
wAD
wAD•2mo ago
umm one sec yeah i dont think its gonna work
Pizza
PizzaOP•2mo ago
oh kk ima test if it inherits with shared component
wAD
wAD•2mo ago
can you try something if it doesnt
/**
* @metadata flamework:implements flamework:parameters injectable intrinsic-component-decorator
*/
export function StructureComponent() {
return Component({
tag: "_structure",
predicate: (instance): instance is Model => {
if (!instance.IsA("Model")) return false;

const base = instance.FindFirstChild("StructureBase");
return base !== undefined && base.IsA("BasePart");
},
refreshAttributes: true,
});
}
/**
* @metadata flamework:implements flamework:parameters injectable intrinsic-component-decorator
*/
export function StructureComponent() {
return Component({
tag: "_structure",
predicate: (instance): instance is Model => {
if (!instance.IsA("Model")) return false;

const base = instance.FindFirstChild("StructureBase");
return base !== undefined && base.IsA("BasePart");
},
refreshAttributes: true,
});
}
(this one should be called) idk if itlll work
Pizza
PizzaOP•2mo ago
hmmm ill try nope 😔
wAD
wAD•2mo ago
:sad:
Pizza
PizzaOP•2mo ago
Argument of type '() => ((ctor: defined) => never) & { _flamework_Decorator: never; }' is not assignable to parameter of type '{ _flamework_Parameters: unknown[]; }'
wAD
wAD•2mo ago
anyways i believe it should inherit if its not its a bug
Pizza
PizzaOP•2mo ago
ok kk also can attributes be instances like a Player for example?
wAD
wAD•2mo ago
no
Pizza
PizzaOP•2mo ago
ok
Pizza
PizzaOP•2mo ago
also the first image with owner is for base structure the one of the right is for base building but do i also have to put owner in the attributes of base building or are they merged?
No description
No description
wAD
wAD•2mo ago
i have no idea sorry
Pizza
PizzaOP•2mo ago
kk nvm

Did you find this page helpful?