Closed xxshady closed 2 years ago
What do you think about adding a different interface for each type of meta and each entity class? e.g. IVehicleSyncedMeta for vehicle synced meta (vehicle.setSyncedMeta
)
Currently stuck on fixing type checking in alt.setMeta
when value
type param does not match the type in ICustomGlobalMeta
import * as alt from "alt-shared"
enum CustomGlobalMeta {
Example = "example",
Example2 = "example2",
}
declare module "alt-shared" {
export interface ICustomGlobalMeta {
[CustomGlobalMeta.Example]: number
[CustomGlobalMeta.Example2]: string
}
}
// 1nd overload setMeta(key: CustomGlobalMeta, value: number)
alt.setMeta(CustomGlobalMeta.Example, 123) // ok
// 2nd overload setMeta(key: string, value: unknown)
alt.setMeta(CustomGlobalMeta.Example, "awdd") // type check is ignored here
@C0kkie, can you check to see if it's too messed up?
Is this still a draf or
@C0kkie yes its still a draft because some interfaces and overloads havent been added yet, i just want to know if its worth it so i can add the rest
I didn't add meta interfaces for some classes (worldobject, some child colshape classes, child blip classes) because I think they are unnecessary
Now we need to pass generic parameter into meta methods every time, and there is no autocomplete for the meta keys in current solution, so its not very convenient.
I added empty interfaces for global meta, player, entity (currently) to be extended by users, which works just like the event functions. (e.g.
alt.on
withalt.IClientEvent
)Example usage