Had this question answered and is somewhat similar but this question requires using Generics while enforcing parameter type to have some common fields.
type Document = {
Name: string
Version: string
}
let inline requestData<'t> (document: 't) =
Console.WriteLine(document.Name)
Console.WriteLine(document.Version)
Test
requestData<Document>({Name = "test"; Version="259723983"})
The error I'm getting is
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constraint the type of the object. This may allow the lookup to be resolved.
Edit
let inline requestData<'t> (document: 't) =
let name = (^document: (member Name: string)(document))
The declared type parameter
t'cannot be used here since the type parameter cannot be resolved at compile time.
requestDatashould work the same as withsomeComplexFunin the answer you linked - you just need to declare the statically resolved member access instead of callingdocument.Namedirectly - Honza Brestan