create-genshin-ts 0.1.5 → 0.1.7
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/README.md
CHANGED
|
@@ -7,3 +7,6 @@ Scaffold a Genshin-TS project.
|
|
|
7
7
|
```bash
|
|
8
8
|
npm create genshin-ts@latest
|
|
9
9
|
```
|
|
10
|
+
|
|
11
|
+
genshin-ts includes a TypeScript plugin for more advanced TypeScript support enhancements; even if it is not enabled, it does not affect functionality or development workflow, but enabling it is recommended. See:
|
|
12
|
+
[https://gsts.moe/doc/quick-start/install.html#typescript-plugin](https://gsts.moe/doc/quick-start/install.html#typescript-plugin)
|
package/package.json
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"[javascriptreact]": {
|
|
16
16
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
17
17
|
},
|
|
18
|
+
"editor.codeActionsOnSave": {
|
|
19
|
+
"source.fixAll.eslint": "always"
|
|
20
|
+
},
|
|
21
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
22
|
+
"typescript.enablePromptUseWorkspaceTsdk": true,
|
|
18
23
|
"search.exclude": {
|
|
19
24
|
"package-lock.json": true
|
|
20
25
|
},
|
|
@@ -123,6 +123,9 @@ Disable an option temporarily if you need to debug or compare graphs.
|
|
|
123
123
|
|
|
124
124
|
- `number` is **float**; `bigint` is **int**.
|
|
125
125
|
- Use `bigint` for modulo/bitwise operations.
|
|
126
|
+
- When list indexing uses `bigint` / `IntValue`, wrap with `idx(...)`, e.g. `arr[idx(i)]` (you can apply this via ESLint auto-fix).
|
|
127
|
+
- If this is shown as a warning (not an error), the TypeScript plugin is usually active and already treats `bigint` as a valid index value; you may disable `gsts/bigint-index-in-server`.
|
|
128
|
+
- If `TS2538` still appears as an error in VSCode/Cursor, configure `"typescript.tsdk": "node_modules/typescript/lib"` and `"typescript.enablePromptUseWorkspaceTsdk": true` (the genshin-ts project template already includes these settings), then switch to the workspace TypeScript version.
|
|
126
129
|
- Lists/dicts must be homogeneous; mixed types will fail.
|
|
127
130
|
- Empty arrays may not infer a type; add a typed placeholder or use `list(...)`.
|
|
128
131
|
- Prefer explicit helpers: `int`, `float`, `vec3`, `configId`, `prefabId`, `entity`, etc.
|
|
@@ -138,6 +141,7 @@ Logging and debug:
|
|
|
138
141
|
|
|
139
142
|
Type helpers:
|
|
140
143
|
- `bool(...)` / `int(...)` / `float(...)` / `str(...)`
|
|
144
|
+
- `idx(...)`: helps `bigint` / `IntValue` index expressions pass TypeScript type-checking (type-check only; node-graph int semantics stay unchanged).
|
|
141
145
|
- `vec3(...)` / `guid(...)` / `prefabId(...)` / `configId(...)` / `faction(...)` / `entity(...)`
|
|
142
146
|
- `list('int', items)`: explicit list typing (critical for empty arrays).
|
|
143
147
|
- `dict(...)`: read-only dict.
|
|
@@ -128,6 +128,9 @@ g.server({
|
|
|
128
128
|
|
|
129
129
|
- `number` 会视为 **float**,`bigint` 会视为 **int**。
|
|
130
130
|
- 取余、位运算等整数运算请使用 `bigint`。
|
|
131
|
+
- 列表下标若使用 `bigint` / `IntValue`,请用 `idx(...)` 包裹,例如 `arr[idx(i)]`(可直接应用 ESLint 自动修复)。
|
|
132
|
+
- 若此处显示为“警告”而非“错误”,通常表示项目 TypeScript 插件已生效(已将 `bigint` 视作可索引),可按需禁用 `gsts/bigint-index-in-server`。
|
|
133
|
+
- 若 VSCode/Cursor 里仍看到 `TS2538` 错误,请配置 `"typescript.tsdk": "node_modules/typescript/lib"` 与 `"typescript.enablePromptUseWorkspaceTsdk": true`(genshin-ts 的项目模板已经自带这些设置),并设置“使用工作区 TypeScript 版本”。
|
|
131
134
|
- 列表/字典元素类型必须一致,混合类型会报错。
|
|
132
135
|
- 空数组可能无法推断类型,建议先放一个同类型占位值。
|
|
133
136
|
- 建议使用辅助函数明确类型:`int`、`float`、`vec3`、`configId`、`prefabId`、`entity` 等。
|
|
@@ -145,6 +148,7 @@ g.server({
|
|
|
145
148
|
类型与构造:
|
|
146
149
|
|
|
147
150
|
- `bool(...)` / `int(...)` / `float(...)` / `str(...)`:显式类型转换。
|
|
151
|
+
- `idx(...)`:用于让 `bigint` / `IntValue` 索引通过 TypeScript 类型检查(仅用于通过类型检查,不改变节点图整数语义)。
|
|
148
152
|
- `vec3(...)` / `guid(...)` / `prefabId(...)` / `configId(...)` / `faction(...)` / `entity(...)`:常用类型构造。
|
|
149
153
|
- `list('int', items)`:显式声明列表类型(空数组时尤为重要)。
|
|
150
154
|
- `dict(...)`:声明只读字典(节点图变量字典需用 `f.get` / `f.set`)。
|