typed-factorio 0.19.1 → 1.0.0-RC
Sign up to get free protection for your applications and to get access to all the features.
- package/Changelog.md +14 -8
- package/README.md +19 -14
- package/custom-index-template.d.ts +22 -0
- package/generated/classes.d.ts +366 -76
- package/generated/concepts.d.ts +3 -3
- package/generated/events.d.ts +138 -140
- package/generated/index-types.d.ts +49 -0
- package/package.json +2 -5
- package/runtime/index.d.ts +9 -1
- package/runtime/pairs.d.ts +4 -8
- package/strict-index-types.d.ts +3 -0
- package/generated/index.d.ts +0 -9
package/Changelog.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# v0.20.0
|
2
|
+
|
3
|
+
- Updated to factorio version 1.1.56
|
4
|
+
- This is an **opt-in** feature: Some numeric types which represent indices/number,e.g. player_index, entity_number, are now branded numbers with their own type, e.g. `PlayerIndex` and `EntityNumber`. See the README for more info.
|
5
|
+
- Added custom-index-template.d.ts to assist trying out custom changes to types in a project.
|
6
|
+
|
1
7
|
# v0.19.0
|
2
8
|
|
3
9
|
- Updated to factorio version 1.1.53
|
@@ -33,8 +39,8 @@
|
|
33
39
|
# v0.15.0
|
34
40
|
|
35
41
|
- Table or array concepts are now declared in table form wherever it is an "read" position.
|
36
|
-
|
37
|
-
|
42
|
+
- This works with setter overloading for applicable properties: `player.color.x; player.color = [1, 1, 1]` is now valid!
|
43
|
+
- This also applies to concepts/complex types which contain table_or_array properties.
|
38
44
|
- Some concepts now also have a special form where it is known to be in a "read" position, where all table_or_array concepts are declared in table form. These concepts are suffixed with "Read", e.g. `ScriptAreaRead`.
|
39
45
|
- Arrays which are known to be in a "write" only form (e.g. method parameters) now are marked readonly. This means you can now pass readonly arrays to these methods.
|
40
46
|
- `MapPosition` is now a table or array concept.
|
@@ -50,17 +56,17 @@
|
|
50
56
|
- LuaStyle size, margin/padding setters now have more specific array types. These array types are `SizeArray` and `StyleValuesArray` for size and margin/padding, respectively.
|
51
57
|
- `@noSelf` annotation is now only present when necessary.
|
52
58
|
- For classes with subclasses:
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
59
|
+
- The original class name (e.g. `LuaItemStack`) still contains attributes of all subclasses (same as before).
|
60
|
+
- There is now a `Base` type (e.g. `BaseItemStack`) which only includes attributes common to all subclasses.
|
61
|
+
- There is a separate type definition for each subclass, e.g. `BlueprintItem`. Note that one instance may still belong to multiple subclasses (the subclasses are not mutually exclusive).
|
62
|
+
- The above two can be optionally used for stricter types.
|
57
63
|
|
58
64
|
# v0.13.2
|
59
65
|
|
60
66
|
- Fix: resize_to_sprite property should not be on subclass sprite-button
|
61
67
|
- Fix: ChooseElemButtonSpec filters should be named elem_filters
|
62
68
|
- Switch back to `/latest` api docs link
|
63
|
-
|
69
|
+
- New version of web api docs is now active
|
64
70
|
|
65
71
|
# v0.13.0
|
66
72
|
|
@@ -96,7 +102,7 @@
|
|
96
102
|
# v0.7.3
|
97
103
|
|
98
104
|
- Update to factorio version 1.1.42
|
99
|
-
|
105
|
+
- No api changes, but improvements to descriptions
|
100
106
|
|
101
107
|
# v0.7.2
|
102
108
|
|
package/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Complete and featureful typescript definitions for the Factorio modding lua api. This is intended to be used with [TypescriptToLua](https://typescripttolua.github.io/).
|
4
4
|
|
5
|
-
This project aims to provide type definitions for the Factorio lua API that are as complete as possible. This means no `any`s or `unknown`s, correct nullability, and smart
|
5
|
+
This project aims to provide type definitions for the Factorio lua API that are as complete as possible. This means no `any`s or `unknown`s, correct nullability, and lots of smart type features. The generator integrates both the Factorio JSON api docs and manually defined additions and overrides.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -42,7 +42,7 @@ Example:
|
|
42
42
|
|
43
43
|
```ts
|
44
44
|
import { Data, Mods } from "typed-factorio/data/types"
|
45
|
-
// or
|
45
|
+
// or
|
46
46
|
import { Data, Mods } from "typed-factorio/settings/types"
|
47
47
|
|
48
48
|
declare const data: Data
|
@@ -93,15 +93,6 @@ Variant parameter types (types with "additional fields can be specified dependin
|
|
93
93
|
|
94
94
|
The type for a specific variant is prefixed with the variant name, or with "Other" for variants without additional fields (e.g. `AmmoDamageTechnologyModifier`, `OtherTechnologyModifier`).
|
95
95
|
|
96
|
-
### Types with subclasses
|
97
|
-
|
98
|
-
Some classes have attributes that are documented to only work on particular subclasses. For these classes, e.g. `LuaEntity`, there are also these other types that you can _optionally_ use:
|
99
|
-
|
100
|
-
- a "Base" type, e.g. `BaseEntity`, which only contains members usable by all subclasses
|
101
|
-
- individual subclass types, e.g. `CraftingMachineEntity`, which extends the base type with members specific to that subclass
|
102
|
-
|
103
|
-
The simple class name, `LuaEntity` in this example, still contains attributes for _all_ subclasses.
|
104
|
-
|
105
96
|
### Events
|
106
97
|
|
107
98
|
`script.on_event()`, `script.get/set_filters()`, and `script.raise_event()` all have type checking on the event data/filter type, inferred from what is passed as the event name/id.
|
@@ -120,14 +111,28 @@ Table-or-array types will appear in the Table form when known to be in a read po
|
|
120
111
|
|
121
112
|
For some concepts, there is also a special form for when the concept is used in a "read" position, where all table-or-array types are in Table form. These types are suffixed with `Read`, e.g. `ScriptPositionRead`.
|
122
113
|
|
114
|
+
### Types with subclasses
|
115
|
+
|
116
|
+
Some classes have attributes that are documented to only work on particular subclasses. For these classes, e.g. `LuaEntity`, there are specific types that you can _optionally_ use:
|
117
|
+
|
118
|
+
- a "Base" type, e.g. `BaseEntity`, which only contains members usable by all subclasses
|
119
|
+
- individual subclass types, e.g. `CraftingMachineEntity`, which extends the base type with members specific to that subclass
|
120
|
+
|
121
|
+
The simple class name, `LuaEntity` in this example, contains attributes for _all_ subclasses.
|
122
|
+
|
123
123
|
### LuaGuiElement
|
124
124
|
|
125
125
|
`LuaGuiElement` is broken up into a [discriminated union](https://basarat.gitbook.io/typescript/type-system/discriminated-unions), with a separate type for each gui element type. Individual gui element types can be referred to by `<Type>GuiElement`, e.g. `ButtonGuiElement`.
|
126
126
|
|
127
|
-
Similarly, the table passed to `LuaGuiElement.add`, referred to as `GuiSpec`, is also broken up into a discriminated union
|
127
|
+
Similarly, the table passed to `LuaGuiElement.add`, referred to as `GuiSpec`, is also broken up into a discriminated union. The type for a specific GuiSpec is `<Type>GuiSpec`, e.g. `ListBoxGuiSpec`. `LuaGuiElement.add` will return the appropriate gui element type corresponding to the gui spec type received.
|
128
128
|
|
129
129
|
This is done both to provide more accurate types, and for possible integration with [JSX](https://typescripttolua.github.io/docs/jsx/).
|
130
130
|
|
131
|
-
###
|
131
|
+
### Strict index types
|
132
|
+
|
133
|
+
This is a recommended **opt-in** feature. To opt in, add `"typed-factorio/strict-index-types"` to `compilerOptions > types` in your tsconfig.json (in addition to `"typed-factorio/runtime"`).
|
132
134
|
|
133
|
-
|
135
|
+
Some `uint` types which represent indices, e.g. player_index, entity_number, can be "branded" numbers with their own type, e.g. `PlayerIndex` and `EntityNumber`. These are assignable to `number`, but a plain `number` is not directly assignable to them. This helps ensure correctness.
|
136
|
+
These are indices that do not index into an array-like structure, and otherwise should usually not have arithmetic done to them.
|
137
|
+
You can use these types as keys in an index signature, e.g. `{ [index: PlayerIndex]: "foo" }`.
|
138
|
+
You can cast "plain" numbers to these types, e.g. `1 as PlayerIndex`, do this with caution.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// This references the same files as "typed-factorio/runtime".
|
2
|
+
// For example, if you want to modify a file, copy the file you want to modify to your project and make the changes. Then, copy this template file into your project and remove the line corresponding to modified file.
|
3
|
+
// If you think your modification will be useful to others, please consider making a change suggestion by creating an issue on GitHub.
|
4
|
+
|
5
|
+
/// <reference types="lua-types/5.2" />
|
6
|
+
|
7
|
+
// generated
|
8
|
+
/// <reference types="typed-factorio/generated/builtin-types.d.ts" />
|
9
|
+
/// <reference types="typed-factorio/generated/global-objects.d.ts" />
|
10
|
+
/// <reference types="typed-factorio/generated/defines.d.ts" />
|
11
|
+
/// <reference types="typed-factorio/generated/events.d.ts" />
|
12
|
+
/// <reference types="typed-factorio/generated/classes.d.ts" />
|
13
|
+
/// <reference types="typed-factorio/generated/concepts.d.ts" />
|
14
|
+
/// <reference types="typed-factorio/generated/index-types.d.ts" />
|
15
|
+
|
16
|
+
// other runtime
|
17
|
+
/// <reference types="typed-factorio/runtime/librariesAndFunctions.d.ts" />
|
18
|
+
/// <reference types="typed-factorio/runtime/pairs.d.ts" />
|
19
|
+
|
20
|
+
// lualib
|
21
|
+
/// <reference types="typed-factorio/runtime/util.d.ts" />
|
22
|
+
/// <reference types="typed-factorio/runtime/mod-gui.d.ts" />
|