typed-factorio 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+ // This is an auto-generated file. Do not edit directly!
2
+
3
+ /** @noSelfInFile */
4
+
5
+ /**
6
+ * See {@link LuaPlayer#index LuaPlayer.index}.
7
+ *
8
+ * If using strict-index-types, and you need to use a plain number for this type, you can use a cast, e.g. `1 as PlayerIndex`.
9
+ */
10
+ type PlayerIndex = uint & IndexBrand<"_playerIndexBrand">
11
+
12
+ /**
13
+ * See {@link LuaSurface#index LuaSurface.index}.
14
+ *
15
+ * If using strict-index-types, and you need to use a plain number for this type, you can use a cast, e.g. `1 as SurfaceIndex`.
16
+ */
17
+ type SurfaceIndex = uint & IndexBrand<"_surfaceIndexBrand">
18
+
19
+ /**
20
+ * See {@link LuaEntity#unit_number LuaEntity.unit_number}.
21
+ *
22
+ * If using strict-index-types, and you need to use a plain number for this type, you can use a cast, e.g. `1 as UnitNumber`.
23
+ */
24
+ type UnitNumber = uint & IndexBrand<"_unitNumberBrand">
25
+
26
+ /**
27
+ * See {@link LuaGuiElement#index LuaGuiElement.index}.
28
+ *
29
+ * If using strict-index-types, and you need to use a plain number for this type, you can use a cast, e.g. `1 as GuiElementIndex`.
30
+ */
31
+ type GuiElementIndex = uint & IndexBrand<"_guiElementIndexBrand">
32
+
33
+ /**
34
+ * See {@link LuaBootstrap#register_on_entity_destroyed LuaBootstrap.register_on_entity_destroyed}.
35
+ *
36
+ * If using strict-index-types, and you need to use a plain number for this type, you can use a cast, e.g. `1 as RegistrationNumber`.
37
+ */
38
+ type RegistrationNumber = uint64 & IndexBrand<"_registrationNumberBrand">
39
+
40
+ interface __OptInFeatures {}
41
+
42
+ /**
43
+ * Equals a branded type when __OptInFeatures contains strictIndexTypes, otherwise equals `unknown`.
44
+ */
45
+ type IndexBrand<B extends string> = "strictIndexTypes" extends keyof __OptInFeatures
46
+ ? {
47
+ [K in B]: any
48
+ }
49
+ : unknown
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typed-factorio",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
5
  "keywords": [
6
6
  "factorio",
@@ -15,9 +15,7 @@
15
15
  ],
16
16
  "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
17
17
  "scripts": {
18
- "gen": "ts-node -P generator/tsconfig.json generator/main.ts",
19
- "generate": "yarn run gen --in ./generatorSrc --out ./generated --warn-as-error",
20
- "generate:dev": "yarn run gen --in ./generatorSrc --out ./generated --no-format",
18
+ "generate": "ts-node -P generator/tsconfig.json generator/main.ts",
21
19
  "clean": "rimraf generated",
22
20
  "pretest": "yarn run generate",
23
21
  "test": "jest",
@@ -37,7 +35,6 @@
37
35
  "@typescript-eslint/eslint-plugin": "^5.6.0",
38
36
  "@typescript-eslint/parser": "^5.6.0",
39
37
  "chalk": "^3.0.0",
40
- "commander": "^8.3.0",
41
38
  "eslint": "^8.4.1",
42
39
  "eslint-config-prettier": "^8.3.0",
43
40
  "eslint-config-standard": "^16.0.3",
@@ -1,7 +1,15 @@
1
1
  /// <reference types="lua-types/5.2" />
2
2
 
3
- /// <reference path="../generated/index.d.ts" />
3
+ // generated
4
+ /// <reference path="../generated/builtin-types.d.ts" />
5
+ /// <reference path="../generated/global-objects.d.ts" />
6
+ /// <reference path="../generated/defines.d.ts" />
7
+ /// <reference path="../generated/events.d.ts" />
8
+ /// <reference path="../generated/classes.d.ts" />
9
+ /// <reference path="../generated/concepts.d.ts" />
10
+ /// <reference path="../generated/index-types.d.ts" />
4
11
 
12
+ // other runtime
5
13
  /// <reference path="librariesAndFunctions.d.ts" />
6
14
  /// <reference path="pairs.d.ts" />
7
15
 
@@ -1,14 +1,10 @@
1
1
  /** @noSelfInFile */
2
-
3
- /**
4
- * Iterating with `pairs` will only iterate the array part of a {@link LuaCustomTable}.
5
- *
6
- * **Note**: you can also iterate on a LuaCustomTable directly without using `pairs`, e.g. `for(const [k, v] of table)`.
7
- */
8
- declare function pairs<V>(table: LuaCustomTable<number | string, V>): LuaIterable<LuaMultiReturn<[number, V]>>
2
+ ///<reference types="lua-types/5.2" />
9
3
 
10
4
  /** **Note**: you can also iterate on a LuaCustomTable directly without using `pairs`, e.g. `for(const [k, v] of table)`. */
11
- declare function pairs<K extends number | string, V>(table: LuaCustomTable<K, V>): LuaIterable<LuaMultiReturn<[K, V]>>
5
+ declare function pairs<T extends LuaCustomTable<any, any>>(
6
+ table: T
7
+ ): LuaIterable<LuaMultiReturn<T extends Iterable<infer E> ? E : never>>
12
8
 
13
9
  /** @deprecated {@link LuaCustomTable} cannot be iterated with `ipairs`; Use {@link pairs} instead. */
14
10
  declare function ipairs(table: LuaCustomTable<any, any>): never
@@ -0,0 +1,3 @@
1
+ interface __OptInFeatures {
2
+ strictIndexTypes: true
3
+ }
@@ -1,9 +0,0 @@
1
- // This is an auto-generated file. Do not edit directly!
2
-
3
- ///<reference types="lua-types/5.2" />
4
- ///<reference path="builtin-types.d.ts" />
5
- ///<reference path="global-objects.d.ts" />
6
- ///<reference path="defines.d.ts" />
7
- ///<reference path="events.d.ts" />
8
- ///<reference path="classes.d.ts" />
9
- ///<reference path="concepts.d.ts" />