@nativewrappers/fivem 0.0.143 → 0.0.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The convar type that will be used for the specified decor
|
|
3
|
+
*/
|
|
1
4
|
export declare enum ConVarType {
|
|
2
5
|
String = 0,
|
|
3
6
|
Integer = 1,
|
|
4
7
|
Float = 2,
|
|
5
8
|
Boolean = 3
|
|
6
9
|
}
|
|
7
|
-
export type DeserializeFn = (data:
|
|
10
|
+
export type DeserializeFn<T extends ConVarType> = (data: InferType<T>) => any;
|
|
11
|
+
type InferType<T extends ConVarType> = T extends ConVarType.String ? string : T extends ConVarType.Integer ? number : T extends ConVarType.Float ? number : T extends ConVarType.Boolean ? boolean : never;
|
|
8
12
|
/**
|
|
9
13
|
* Gets the specified `ConVar`s value, this will bind to the parameter of the current class
|
|
10
14
|
* updating it whenever the ConVar value changes.
|
|
@@ -48,4 +52,5 @@ export type DeserializeFn = (data: unknown) => unknown;
|
|
|
48
52
|
* }
|
|
49
53
|
* ```
|
|
50
54
|
*/
|
|
51
|
-
export declare function ConVar(name: string, convarType:
|
|
55
|
+
export declare function ConVar<T extends ConVarType>(name: string, convarType: T, deserialize?: DeserializeFn<T>): (_initialValue: any, context: ClassFieldDecoratorContext, ..._args: any[]) => void;
|
|
56
|
+
export {};
|
package/common/decors/ConVar.js
CHANGED
|
@@ -21,7 +21,7 @@ const getConvarFunction = /* @__PURE__ */ __name((con_var_type) => {
|
|
|
21
21
|
// needed so typescript wont complain about "unreachable code" for the error below
|
|
22
22
|
default:
|
|
23
23
|
}
|
|
24
|
-
throw new Error(
|
|
24
|
+
throw new Error(`Got conVarType: ${con_var_type} but it was not a valid ConVar type, please refer to "ConVarType"`);
|
|
25
25
|
}, "getConvarFunction");
|
|
26
26
|
function ConVar(name, convarType, deserialize) {
|
|
27
27
|
return /* @__PURE__ */ __name(function actualDecorator(_initialValue, context, ..._args) {
|