Refactor: Make defineString generic for better type-safety#1693
Refactor: Make defineString generic for better type-safety#1693keeganpotgieter wants to merge 2 commits intofirebase:masterfrom
defineString generic for better type-safety#1693Conversation
c4788a9 to
5e88ed1
Compare
|
/gemini |
There was a problem hiding this comment.
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.
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