ts-case-convert icon indicating copy to clipboard operation
ts-case-convert copied to clipboard

fix: Corrected ObjectToCamel, ObjectToPascal, ObjectToSnake types

Open ryanhaugh opened this issue 1 year ago • 10 comments

There is an issue with the ObjectToCamel, ObjectToPascal, ObjectToSnake where they don't handle an array of string number unions correctly.

For example, the following:

ObjectToCamel<{
  prop_name: ("a" | "b" | "c")[];
}>

incorrectly returns:

{
    propName: "a"[] | "b"[] | "c"[];
}

when it should return:

{
    propName: ("a" | "b" | "c")[];
}

This PR fixes ObjectToCamel, ObjectToPascal, ObjectToSnake to return the correct string/number union array type.

ryanhaugh avatar Aug 01 '24 21:08 ryanhaugh

Frankly, seeing fixes like this hang for months is discouraging when the library is as popular as it is.

BigBallard avatar Sep 19 '24 14:09 BigBallard

Frankly, seeing fixes like this hang for months is discouraging when the library is as popular as it is.

@BigBallard If you want to re-write the PR so it doesn't reformat all the lines then I will look at it.

RossWilliams avatar Sep 19 '24 16:09 RossWilliams

@ryanhaugh If you can preserve existing formatting then I can look at these changes.

RossWilliams avatar Sep 29 '24 18:09 RossWilliams

@RossWilliams apologies for all the formatting changes - I've fixed them.

ryanhaugh avatar Oct 04 '24 06:10 ryanhaugh

This PR also fixes this issue:

ObjectToCamel<{
  property_name: undefined;
}>;

incorrectly returns:

{
  propertyName: unknown[];
}

when it should return:

{
  propertyName: undefined;
}

@RossWilliams let me know if you need anything else from me so we can get this across the line - thanks!

ryanhaugh avatar Oct 10 '24 15:10 ryanhaugh

@ryanhaugh Build fails, you need to adjust the tests.

RossWilliams avatar Oct 10 '24 15:10 RossWilliams

@RossWilliams I've simplified ObjectToCamel, ObjectToPascal, ObjectToSnake. I've also ensured all existing tests pass and have added more tests to ensure the bugs I've found are fixed with my PR.

ryanhaugh avatar Oct 17 '24 05:10 ryanhaugh

@RossWilliams any chance you could take another look at this PR? Thanks! Ryan

ryanhaugh avatar Oct 21 '24 16:10 ryanhaugh

@RossWilliams anything I can do to help move this along?

ryanhaugh avatar Nov 01 '24 18:11 ryanhaugh

Starting to think this won't be reviewed - please prove me wrong.

ryanhaugh avatar Nov 09 '24 01:11 ryanhaugh

Just tagging @RossWilliams so he knows that we are all annoyed :D.

PS: honstely, thanks for the library!! Please click the 2 buttons to merge and release!

Fuzzyma avatar Dec 02 '25 16:12 Fuzzyma