@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: unknown) => unknown;
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: ConVarType, deserialize?: DeserializeFn): (_initialValue: any, context: ClassFieldDecoratorContext, ..._args: any[]) => void;
55
+ export declare function ConVar<T extends ConVarType>(name: string, convarType: T, deserialize?: DeserializeFn<T>): (_initialValue: any, context: ClassFieldDecoratorContext, ..._args: any[]) => void;
56
+ export {};
@@ -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("Got invalid ConVarType");
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) {
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.143",
11
+ "version": "0.0.144",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"