handsontable
handsontable copied to clipboard
[Bug]: Return type of propToCol method is returning string | number type
Describe the bug
I recently upgraded to new 14.0.0 release and encountered this type error.
Video/Screenshots
We cannot do setCellMeta
along with propToCol
because we are having type collisions. setCellMeta
only uses number for col property and not string | number
Provide a link to the demo with the bug reproduction
No response
Handsontable version
14.0.0
Framework version
No response
Your environment
macOS, Chrome latest
Hi @rmlevangelio
Thank you for reporting this. We will take care of this issue in the next sprint. We will update this thread once it's released.
@rmlevangelio I investigated the issue, and it seems that the typing for the propToCol
method is correct. The typing is more consistent with what the method actually returns. In some cases, for example, when the Handsontable is not initialized with columns mapping calling the method with string returns the same string.
hot.propToCol('test') === 'test' // true
I'd recommend adding an additional if to your code that would check if the returned value is a number.
@budnix I think this change is disruptive. It will be so tedious for all the devs to put assertion methods in all places where hot.propToCol
exists just make sure the return value is a number
. Also this is not added as part of breaking changes in release notes.
https://handsontable.com/docs/react-data-grid/api/core/#proptocol
This is the previous docs and it clearly shows that the previous return type is number.
@rmlevangelio I generally agree with you it'd be much better if the method would return one type. I marked the issue with an additional label which indicates that we need to take a closer look at it.
Hi @rmlevangelio
Again, thank you for sharing the issue report.
I have great news! We just published Handsontable v14.2 when this issue is fixed.
Related PR: https://github.com/handsontable/handsontable/pull/10750 Release notes: https://handsontable.com/docs/javascript-data-grid/release-notes/#_14-2-0
@AMBudnik amazing! Thank you!