#Mapping type of nested function
1 messages · Page 1 of 1 (latest)
U set x to any thats why remove x and keep U
--!strict
local stringTable = {
hello = print("hello"),
test = print("test"),
wow = print("wow")
}
type StringTable = typeof(stringTable)
type Acceptance = keyof<StringTable>
type InnerFunction = <U>(x: Acceptance | U) -> index<StringTable, U>
local function foo(): InnerFunction
return function<U>(x: Acceptance | U): index<StringTable, U>
return x
end
end
local test = foo()("test")
--local test: index<{
-- hello: nil,
-- test: nil,
-- wow: nil
--}, unknown>
-- now its unkown
any idea about this?
this was a very simplified version which works
ig