No valid instantiation could be inferred for generic type parameter V. It was expected to be at least: number

Hi everyone, I am abit new to type checking and I am stuck on this weird error while creating a Profile class by using the ProfileStore module.

This is my code.. apparently when I try to insert a number into the table, I am met with that error (In the title).

function ProfileController.Get(self : ProfileController, Player : Player) : Profile.Profile?
	table.insert(self.Profiles[Player].Session.Data.Passes, 3)
	return self.Profiles[Player]
end
-- Error highlights on table.insert.
-- Another snippet

function ProfileController.Register(self : ProfileController, Player : Player) : Profile.Profile
	self.Profiles[Player] = Profile.new(Player) :: Profile.Profile
	return self.Profiles[Player]
end

Snippet of ProfileClass:

local Profile = {}
Profile.__index = Profile



Profile.Template = {
	Passes = {} :: {number},
	PsuedoPasses = {} :: {number},
} 

Profile.PlayerStore = ProfileStore.New("DataStore", Profile.Template)





export type Template = typeof(Profile.Template)
export type Session = ProfileStore.Profile<Template>
export type Profile = typeof(setmetatable({} :: {Player : Player, Session : Session}, Profile))


function Profile.new(Player : Player, Reconcile : boolean?) : Profile?
	local self = setmetatable({Player = Player}, Profile) :: Profile

	self.Session = Profile.PlayerStore:StartSessionAsync(`{Player.UserId}`, {
		Cancel = function()
			return not Player:IsDescendantOf(Players)
		end,
	}) :: Session

	if not self.Session or not Player:IsDescendantOf(Players) then
		self:Destroy()
		self.Player:Kick("Profile couldn't load - Please Rejoin.")
		return nil 
	end
	
	Reconcile = Reconcile or true --> Default Value.
	if Reconcile then
		self.Session:Reconcile()
	end
	return self
end

Hey, I am not 100% sure if this helps, but it’s worth trying. Simply store the deeply nested table in a local variable first.

function ProfileController.Get(self : ProfileController, Player : Player) : Profile.Profile?
	local profile = self.Profiles[Player]
	
	if not profile then
		return nil
	end

	local passes = profile.Session.Data.Passes 
	
	table.insert(passes, 3)

	return profile
end
export type ProfileObject = {
	Player: Player,
	Session: Session,
}

export type Profile = ProfileObject & typeof(Profile)

function Profile.new(Player : Player, Reconcile : boolean?) : Profile?
	local self = setmetatable({
		Player = Player
	} :: ProfileObject, Profile) 
    -- ... rest of code

However, the local variable fix above should solve your error without needing to rewrite your class structure, hopefully.