Issues with Custom Type

The Issue: Receiving two type errors while trying to add objects of type “component” to a table. I don’t want these values to be converted in the first place, & I’m not sure why it’s attempting to do so.
image
image

World.lua (main):

--!strict

-- Global Types
local Types = require(script.Types)

-- Module Table
local World = {}
World.__index = World






--[[ World Constructor ]]
function World.new():Types.World
	return setmetatable({
		nextEntityId = 0;
		entities = {}::{number}; 
		components = {}::{Types.component};
		systems = {}::{Types.system};
	}, World)::Types.World
end



--[[ Entity Constructor ]]
function World.addEntity(self: Types.World)
	
	-- Iterate
	self.nextEntityId += 1
	
	-- Instantiate Entity
	table.insert(self.entities, self.nextEntityId)
	
	-- Return Id
	return self.nextEntityId
end



--[[ Add Component ]]
function World.addComponent(self: Types.World, entity: number, componentName: string, data: any)
	self.components[componentName][entity] = data
end

Types.lua:

--!strict

-- Module Table
local Types = {}



--[[ World ]]
export type World = {
	
	-- Properties
	nextEntityId: number;
	entities: {number};
	components: {component};
	systems: {system};
	
	-- Methods
	new: () -> (World);
	addEntity: (self: World) -> (number);
	addComponent: (self: World, entity: number, componentName: string, data: any) -> ();
}



--[[ Component ]]
export type component = {
	[string]: {[number]: any}
}



--[[ System ]]
export type system = (world: World) -> ()



-- Module Table
return Types

I’m not sure if the problem is with the type definition itself, or just how I’m trying to insert it into the components table within the addComponent Method

1 Like

appears to be an issue with the type solver, after slight adjustments the code will still function as intended in spite of the type errors

the warnings are still somewhat annoying though

Why are you returning Tuple?
Just do:
→ World
→ number
etc
Isnt type error says the problem already?