Uh oh!
There was an error while loading. Please reload this page.
Fix complex value return type inference - #102
Conversation
|
I've looked at this and played around a bit. It's definitely an improvement. The previous abstraction was unnecessary. However, it doesn't seem to work with |
To clarify: this PR doesn't break the type inference for So this could be merged as an improvement even if |
Did some testing with this - it looks like in basic cases, groups should just work™! Take this example from the docs: Complex values work as well, like in the example from #44:
However, the fun comes in when you try to use This unfortunately makes sense - the resulting type of the There's also the unfortunate reality that each of the values in In a world of no backwards compat, it might be simpler to structure groups with a builder-style pattern. Something like: constresults=awaitgroup().addStep('name',()=>text({message: 'What is your name?'})).addStep('age',()=>text({message: 'What is your age?'})).addStep('color',({ results })=>multiselect({message: `What is your favorite color ${results.name}?`,options: [{value: 'red',label: 'Red'},{value: 'green',label: 'Green'},{value: 'blue',label: 'Blue'},],})).prompt();This way, the type of How we move forward here is really up to you all. I understand if we don't want to make any breaking API changes, but I don't see how to feasibly wrangle the types here. Then again, there's definitely a good chance I'm misinterpreting the root issue here, so I'm open to other thoughts! Though I think this issue is important (and should likely be tracked via a separate issue), imo this PR is unrelated and should be handled separately. Unless I'm missing anything, this one should be ready to go! |
ulken
commented
Mar 15, 2023
Does If not, I'll go ahead and merge this. |
6520f40 to
c8c4e16Comparechrissantamaria
commented
Mar 15, 2023
hmm, looks like my theory was wrong - just rebased with the latest TS should have all the info it needs to infer types, but I wonder if it bails as soon as any individual prompts consume Regardless, I agree this should be good to merge (feel free to add a changeset if you'd like) - let's track in a separate issue. |
orochaa
commented
Aug 21, 2023
Why hasn't it been merged? |
cpreston321
commented
Aug 21, 2023
@Mist3rBru I wanted to merge this! I wanted to make sure there hasn't been any conflicts with the changes from the changes merged is latest release. I will look into this today! |
@chrissantamaria Is it possible you can add Thanks! |





This PR addresses in an issue discussed in #44, where
selectfields with non-primitive values (originally introduced in #86) are not properly inferring the type of the returned user selection.I did so by removing the
Optionsgeneric from all fields as, from what I can tell, it's effectively representing the same constraint asValue. Typechecking for the build still passes, but there's a chance I broke type inference in some other use case - please double check me here!