import { PathItem, Query, ILens } from './types'; import { Type } from 'free-types-core'; import { Next } from './utils'; import { ModifyPath } from './Modify'; import { Lens } from './Lens'; import { FollowPath, NOT_FOUND } from './Follow'; export { Replace, $Replace }; type Replace> = [ Q ] extends [never] ? Data : _Replace, Data, V>; type ValidValue['path']> = [ Q ] extends [never] ? unknown : Path extends [...any[], infer $T extends Type] ? $T['constraints'] : Path extends [...any[], infer $T extends Type, infer N extends number] ? $T['constraints'][N] : unknown; type _Replace> = I extends L['path']['length'] ? V : F extends NOT_FOUND ? Data : ModifyPath>>; interface $Replace> extends Type<1> { type: _Replace, this[0], V>; }