#how do i narrow an arguments type to that returned by a specific type function but for any argument?

1 messages · Page 1 of 1 (latest)

torn mist
#

i hate when i have fn foo(some_int: anytype) or fn foo(some_TypeFn_return: anytype) and there's no way to communicate the constraints of that argument to both future me and the langserver irt using functions on that type. is there a way if i have some TypeFn(x,y,z) to constrain an argument as being of type TypeFn for any x,y,z passed to it in a way the langserver recognizes and is immediately obvious when i look at the outer functions signature?

#

you can do ```
fn foo(comptime x,y,z) ...
const T = TypeFn(x,y,z)

 but thats annoying and not very clear when reading it later
ionic nebula
#

No. You could document what it needs or run the check at the start of the function body