bito-code-review[bot] commented on PR #37218:
URL: https://github.com/apache/superset/pull/37218#issuecomment-3773895010
<!-- Bito Reply -->
Yes, the types can be improved by making the function generic over the value
type to preserve type safety. This avoids using 'unknown' loosely and ensures
the validator and returned function share the same input type.
**superset-frontend/packages/superset-ui-core/src/utils/withLabel.ts**
```
export default function withLabel<T>(
validator: (v: T, state?: any) => string | false,
label: string,
): (v: T, state?: any) => string | false {
return (v: T, state?: any) => {
const error = validator(v, state);
return error ? `${label} ${error}` : false;
};
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]