luau: function parameters are being inferred despite having a type attached

edit: it also turns out that these unknown types get casted?


frameData is unknown but for some reason it’s getting casted to CFrame (AtCoordinate requires a CFrame, ‘frameData’ shouldn’t have the completion for CFrame here)

function parameters get typed as unknown despite them being typed, luau does recognize the type of the rhs but does not assist the developer by providing types for it

local FramedataOnHitGeneric: index<FramedataTypes.Framedata<Framedata, Entity.Entity>, "OnHit"> = function(onEntity, targetEntity, frameData)
	
end
export type Framedata<T, E> = {
	-- How many frames it will take before an active Hitbox appears.
	StartupFrames: number,
	
	-- How many frames the Hitbox will be out for after the Startup frames are complete. 
	ActiveFrames: number,
	
	-- How many frames it will take before the entity executing this attack
	RecoveryFrames: number,
	
	-- If set, this FrameData will be linked into after the recovery frames
	-- are finished.
	--
	-- This can be used to make rekka-like attacks.
	LinksInto: Framedata<any, any>?,
	
	OnHit: (onEntity: E, targetEntity: E, frameData: T) -> any,
	
	-- Functions underneath "namespaces" to be called when a specific frame arrives. 
	Effects: {EffectNamespace<T, E>}?,
	
	-- Properties dictating how the Framedata should determine if another Entity is hit.
	Hitbox: Hitbox?,
}

export type Hitbox = {
	-- What Limb this Hitbox will be relative to.
	-- Defaults to the HumanoidRootPart if unset.
	RelativeTo: (Enum.Limb | string)?,
	
	-- The Offset of the Hitbox, applied in the object-space of the "RelativeTo" field. 
	Offset: Vector3?,
	
	-- The Offset of the Hitbox, applied in world-space.
	OffsetWorldSpace: Vector3?,
	
	-- The Size of the Hitbox.
	-- If set to a number, the size of the Hitbox will be the size of the "RelativeTo" field scaled by the number.
	-- If unset, this will default to the cumulative size of the "RelativeTo" field.
	Size: (Vector3 | number)?,
}

Luau DOES know the types of these, because if I dare choose to type these parameters against what OnHit requires, it gets flagged:
RobloxStudioBeta_doOIUrHYVp

Thanks for the report! The issue here is not that FramedataOnHitGeneric doesn’t have a type (that’s why you get an error when you annotate the fields wrong), but that bidirectional typing is not firing correctly when using a type function as the expected type. It’s likely giving up too early (when it sees the index type function), and so is not able to provide the context that the lambda function must have the desired parameter types. We’re looking into this, along side a number of other bugs that have cropped up with bidirectional typing.