Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F.AutoPath doesn't work if O includes string values #276

Open
nandorojo opened this issue Nov 30, 2021 · 1 comment
Open

F.AutoPath doesn't work if O includes string values #276

nandorojo opened this issue Nov 30, 2021 · 1 comment

Comments

@nandorojo
Copy link

nandorojo commented Nov 30, 2021

🐞 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

Screen Shot 2021-11-30 at 4 50 31 PM

Screen Shot 2021-11-30 at 4 50 36 PM

Additional context

@omerman
Copy link

omerman commented Dec 9, 2021

Experience this as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants