justarandomgeek / vscode-factoriomod-debug

Factorio Mod Tool Kit
Other
122 stars 26 forks source link

data type recipe trigger false warning for category #131

Closed Stargateur closed 3 months ago

Stargateur commented 3 months ago
data:extend({ {
  type = "recipe",
  name = "foo",
  enabled = "false",
  category = "advanced-crafting",
  ingredients = { }
  result = "foo"
} })
Cannot assign `string` to `("alert"|"ambient"|"environment"|"game-effect"|"gui-effect"...(+2))?`.
- `string` cannot match `("alert"|"ambient"|"environment"|"game-effect"|"gui-effect"...(+2))?`
- `string` cannot match any subtypes in `("alert"|"ambient"|"environment"|"game-effect"|"gui-effect"...(+2))?`
- Type `string` cannot match `nil`
- Literal `"advanced-crafting"` cannot match string `"wind"`
- Literal `"advanced-crafting"` cannot match string `"alert"`
- Literal `"advanced-crafting"` cannot match string `"walking"`
- Literal `"advanced-crafting"` cannot match string `"environment"`
- Literal `"advanced-crafting"` cannot match string `"ambient"`
- Literal `"advanced-crafting"` cannot match string `"gui-effect"`
- Literal `"advanced-crafting"` cannot match string `"game-effect"`Lua Diagnostics.(assign-type-mismatch)
(field) category: ("alert"|"ambient"|"environment"|"game-effect"|"gui-effect"...(+2))?
This defines which slider in the sound settings affects the volume of this sound. Furthermore, some sound types are mixed differently than others, e.g. zoom level effects are applied.

-- This defines which slider in the sound settings affects the volume of this sound. Furthermore, some sound types are mixed differently than others, e.g. zoom level effects are applied.
data.SoundType:
    | "game-effect"
    | "gui-effect"
    | "ambient"
    | "environment"
    | "walking"
    | "alert"
    | "wind"

witch is incorrect https://lua-api.factorio.com/latest/prototypes/RecipePrototype.html#category https://wiki.factorio.com/Data.raw#recipe-category

justarandomgeek commented 3 months ago
data:extend({ {
  type = "recipe",
  name = "foo",
  enabled = "false",
  category = "advanced-crafting",
  ingredients = { },
  result = "foo"
} --[[@as data.RecipePrototype]]
})

LuaLS is just bad at narrowing.

Stargateur commented 3 months ago

not perfect but I take it "Cannot assign string to boolean?." oops, nice ! I start to love this vscode extension.