handsontable icon indicating copy to clipboard operation
handsontable copied to clipboard

[Bug]: Return type of propToCol method is returning string | number type

Open rmlevangelio opened this issue 1 year ago • 4 comments

Describe the bug

I recently upgraded to new 14.0.0 release and encountered this type error.

Video/Screenshots

image

We cannot do setCellMeta along with propToCol because we are having type collisions. setCellMeta only uses number for col property and not string | number

image

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

rmlevangelio avatar Dec 01 '23 08:12 rmlevangelio

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.

adrianszymanski89 avatar Dec 01 '23 09:12 adrianszymanski89

@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 avatar Dec 01 '23 09:12 budnix

@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 avatar Dec 01 '23 10:12 rmlevangelio

@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.

budnix avatar Dec 01 '23 10:12 budnix

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 avatar Mar 06 '24 11:03 AMBudnik

@AMBudnik amazing! Thank you!

rmlevangelio avatar Mar 08 '24 12:03 rmlevangelio