- 
                Notifications
    
You must be signed in to change notification settings  - Fork 217
 
          Refactor: Make defineString generic for better type-safety
          #1693
        
          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
base: master
Are you sure you want to change the base?
  
    Refactor: Make defineString generic for better type-safety
  
  #1693
              Conversation
c4788a9    to
    5e88ed1      
    Compare
  
    | 
           /gemini  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a great improvement by making defineString generic, which enhances type-safety when using select options. The use of NoInfer<T> is a good way to control type inference for the default value. However, I've found a critical issue in the implementation of StringParam.runtimeValue that could lead to runtime errors. My review includes a suggestion to fix this. Once that's addressed, this will be a solid refactoring.
| 
           It looks like you tried to invoke a command, but you didn't specify which one. Please use   | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks for the contribution!
I think we'd probably want to add some test cases here -
- Test type narrowing works using select options - perhaps just type assertions?
 - Test backward compatibility without select options
 - Test runtime behavior when env var contains an invalid value?
 - Test edge case when env var is undefined (see comment on the relevant code)
 
Description
The
defineStringfunction does not narrow the type when addinginput.select.options. This means we have to typecast in certain situations, even though we know what the types should be.Code sample
Limitations
defaultValueis provided with no options the value is still wide, rather than loose autocomplete