s2cfgtojson 2.3.0 → 3.0.0
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.
- package/Struct.mts +1 -1
- package/Struct.test.mts +8 -2
- package/package.json +1 -1
- package/types.mts +5 -5
package/Struct.mts
CHANGED
package/Struct.test.mts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { describe, test, expect } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createDynamicClassInstance,
|
|
4
|
+
ERank,
|
|
5
|
+
pad,
|
|
6
|
+
IStruct,
|
|
7
|
+
Struct,
|
|
8
|
+
} from "./Struct.mjs";
|
|
3
9
|
import fs from "node:fs";
|
|
4
10
|
|
|
5
11
|
class ChimeraHPFix extends Struct {
|
|
@@ -196,7 +202,7 @@ struct.end`;
|
|
|
196
202
|
N5 = .1f
|
|
197
203
|
N6 = -2.22f
|
|
198
204
|
struct.end`;
|
|
199
|
-
const str = Struct.fromString<
|
|
205
|
+
const str = Struct.fromString<IStruct & { [key: `N${number}`]: number }>(
|
|
200
206
|
dynamicItemGeneratorText,
|
|
201
207
|
);
|
|
202
208
|
expect(str[0].N1).toBe(0.1);
|
package/package.json
CHANGED
package/types.mts
CHANGED
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
} from "./enums.mjs";
|
|
69
69
|
|
|
70
70
|
export type Internal = "__internal__";
|
|
71
|
-
export type
|
|
71
|
+
export type IStruct = {
|
|
72
72
|
[k in Internal]: DefaultEntries;
|
|
73
73
|
};
|
|
74
74
|
|
|
@@ -87,8 +87,8 @@ export type Value = string | boolean | number;
|
|
|
87
87
|
|
|
88
88
|
export type Entries = Record<string | number, Value>;
|
|
89
89
|
|
|
90
|
-
export type GetTsType<E extends
|
|
91
|
-
[key in Exclude<keyof E, Internal>]: E[key] extends
|
|
90
|
+
export type GetTsType<E extends IStruct> = {
|
|
91
|
+
[key in Exclude<keyof E, Internal>]: E[key] extends IStruct
|
|
92
92
|
? GetTsType<E[key]>
|
|
93
93
|
: E[key];
|
|
94
94
|
};
|
|
@@ -96,9 +96,9 @@ type RKey<In> = Exclude<keyof In, keyof DefaultEntries>;
|
|
|
96
96
|
|
|
97
97
|
export type GetStructType<In> =
|
|
98
98
|
In extends Array<any>
|
|
99
|
-
?
|
|
99
|
+
? IStruct & { [key in number]: GetStructType<In[key]> }
|
|
100
100
|
: In extends Record<any, any>
|
|
101
|
-
?
|
|
101
|
+
? IStruct & { [key in RKey<In>]: GetStructType<In[key]> }
|
|
102
102
|
: In extends string
|
|
103
103
|
? In
|
|
104
104
|
: In extends number
|