Specifying type of function parameter to be caller type

#1

Say I have the following types:

type FirstType<T> {
	myFunction: function(objs: [FirstType])
}

entity type SecondType mixes FirstType<SecondType> schema name STYP

Is there a way that I can specify the input of myFunction to be of the type of whatever is calling it (rather than just FirstType), so that the objs automatically come in as SecondType if we’re calling SecondType.myFunction(...)? I’m facing an issue where my function is unable to take in objects of SecondType when I’m making calls from the UI framework, which is not type system-aware.

0 Likes

#3

You don’t need parametric type in this case:

type FirstType {
	myFunction: function(objs: [mixing FirstType])
}
3 Likes