mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-08-13 00:45:11 +09:00
Remove asserts the types already cover
The nil check burn down added guards which turned out redundant once the surrounding annotations landed. `_has_handlers` is set to true when the first handler registers, so it is a boolean rather than the literal false it was inferred as. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -102,11 +102,11 @@ Elements.reason_confirm = Gui.define("player_list/reason_confirm")
|
||||
local action_name = Elements.container.get_selected_action(player)
|
||||
local button_data = action_name and config.buttons[action_name]
|
||||
if button_data and button_data.reason_callback then
|
||||
local reason = assert(assert(element.parent).entry).text --[[@as string?]]
|
||||
local reason = assert(element.parent).entry.text --[[@as string?]]
|
||||
if reason == nil or not reason:find("%S") then reason = "no reason given" end
|
||||
button_data.reason_callback(player, reason)
|
||||
end
|
||||
assert(assert(element.parent).entry).text = ""
|
||||
assert(element.parent).entry.text = ""
|
||||
Elements.container.set_selected_player(player, nil)
|
||||
Elements.player_table.refresh_player(player)
|
||||
end) --[[@as any]]
|
||||
|
||||
@@ -43,7 +43,7 @@ local function new_quick_action(command, on_click)
|
||||
:style{
|
||||
width = 160,
|
||||
}
|
||||
:on_click(on_click or function(def, player, element, event)
|
||||
:on_click(on_click or function(_def, player, _element, _event)
|
||||
command(player)
|
||||
end)
|
||||
|
||||
|
||||
@@ -270,10 +270,9 @@ Elements.container = Gui.define("research_milestones/container")
|
||||
local milestone_table = Elements.milestone_table(container)
|
||||
Elements.clock_label(header)
|
||||
|
||||
local force = Gui.get_player(parent).force
|
||||
local force = Gui.get_player(parent).force --[[@as LuaForce]]
|
||||
def.data[force] = def.data[force] or {} -- used by start index and row data
|
||||
|
||||
local force = Gui.get_player(parent).force --[[@as LuaForce]]
|
||||
local start_index = Elements.container.calculate_starting_research_index(force)
|
||||
for research_index = start_index, start_index + display_size - 1 do
|
||||
local row_data = Elements.milestone_table.calculate_row_data(force, research_index)
|
||||
@@ -297,7 +296,7 @@ end
|
||||
--- @param research_index number
|
||||
--- @return number
|
||||
function Elements.container.get_achieved_time(force, research_index)
|
||||
return Elements.container.data[force][research_index]
|
||||
return assert(Elements.container.data[force][research_index])
|
||||
end
|
||||
|
||||
--- Calculate the starting research index for a force
|
||||
|
||||
@@ -109,7 +109,7 @@ function Elements.production_label.calculate_display_data(tooltip, value, cutoff
|
||||
end
|
||||
|
||||
local suffix, caption = format_number(value)
|
||||
display_data = display_data or {}
|
||||
display_data = display_data or {} --[[@as Elements.production_label.display_data]]
|
||||
display_data.caption = caption
|
||||
display_data.suffix = suffix
|
||||
display_data.tooltip = tooltip
|
||||
@@ -221,7 +221,7 @@ function Elements.science_table.calculate_row_data(force, science_pack, row_data
|
||||
end
|
||||
|
||||
-- Return the pack data
|
||||
row_data = row_data or {}
|
||||
row_data = row_data or {} --[[@as ExpGui_ScienceProduction.elements.science_table.row_data]]
|
||||
row_data.visible = production.total.made > 0
|
||||
row_data.science_pack = science_pack
|
||||
row_data.icon_style = icon_style
|
||||
|
||||
@@ -612,7 +612,7 @@ function Elements.confirm_task_button.parse(message)
|
||||
-- Trim the spaces of the string
|
||||
local trimmed = string.gsub(message, "^%s*(.-)%s*$", "%1")
|
||||
local title, body = string.match(trimmed, "(.-)\n(.*)")
|
||||
local parsed = { title = title, body = body }
|
||||
local parsed = { title = title, body = body } --[[@as { title: string, body: string }]]
|
||||
if not title then
|
||||
-- If it doesn't match the pattern return the str as a title
|
||||
parsed.title = trimmed
|
||||
|
||||
Reference in New Issue
Block a user