Type 'Part' could not be converted into 'Instance' in an invariant context

So basically i was just messing around w types and i have come to this error, I have no clue why this happens since it works fine when i just remove the obj part of the type

--!strict
local ts = game:GetService("TweenService")
local module = {}

type tweenargs = {
	obj: Instance,
	time: number,
	easingstyle: Enum.EasingStyle?,
	goal: {[any]: any}
}

function module.Tween(args: tweenargs)
	if typeof(args) ~= "table" then 
		warn("tween requires a table vro") 
		return 
	end
	
	local tf = TweenInfo.new(args.time, args.easingstyle)
	local tween = ts:Create(args.obj, tf, args.goal)
	
	return tween
end

local inst = Instance.new("Part", workspace)
local args = {
	obj = inst,
	time = 25,
	easingstyle = Enum.EasingStyle.Linear,
	goal = {5}
}

module.Tween(args)

return module

(I’m just testing that’s why I’m calling it in the same module)
It errors when i call the function and gives me that error
Screenshot 2025-03-22 141533

I’m just completely lost on what the problem is. Any help appreciated

The type checker is just wrong here. A Part is always an Instance. There are many cases where the checker will give wrong results, but they never affect execution, so don’t worry about it too much: Deep Dive: Does Luau have Type Checking?

1 Like

Oh i see, Though i just removed the script completely because it was erroring cause of that