import { self, Param, Output, Key, PathItem, Fn, NOT_FOUND } from './types'; import { Type, inferArgs, Generic, apply } from 'free-types-core'; import { IsAny, Parameters } from './utils'; export { FollowPath, NOT_FOUND }; type FollowPath = undefined extends I ? NOT_FOUND : I extends Output ? Data extends Fn ? ReturnType : NOT_FOUND : I extends Param ? Data extends Fn ? IfDefined[I['key']]> : NOT_FOUND : I extends Key ? Data extends ReadonlyArray ? I extends keyof Data ? IfDefined : NOT_FOUND : Data extends Record ? I extends keyof Data ? Data[I] : NOT_FOUND : NOT_FOUND : I extends self ? Self : I extends Type ? FreeTypeArgs : NOT_FOUND; type IfDefined = IsAny extends true ? T : [T] extends [undefined] ? NOT_FOUND : T; type FreeTypeArgs = apply<$T, any[]> extends T ? T extends Generic<$T> ? inferArgs : NOT_FOUND : NOT_FOUND;