`F.AutoPath` doesn't work if `O` includes `string` values
nandorojo opened this issue Β· comments
Fernando Rojo commented
π Bug Report
Describe the bug
If you pass F.AutoPath<O, S>
where O
includes a string
as one of its values, you get no autocomplete.
F.AutoPath<{ user: boolean }, S> // works
F.AutoPath<{ user: string }, S> // breaks
Reproduce the bug
See here.
import { F, O, S } from 'ts-toolbelt'
declare function get<Ob extends object, P extends string>(
object: Ob,
path: F.AutoPath<Ob, P>
): O.Path<Ob, S.Split<P, '.'>>
const works = get({ fast: true }, '') // β
this errors
const breaks = get({ car: 'toyota' }, '') // π¨ no error here, but it should
Expected behavior
Strings should work like any other field.
Possible Solution
Use F.AutoPath<O, S> | keyof O
Screenshots
Additional context
Omer commented
Experience this as well!