Skip to content

Conversation

@josh-willis-arcadis
Copy link
Contributor

Refactored a core-util function to only return stop_code if found for display in the UI. UI language has been updated to reflect these changes in the packages itinerary-body and printable-itinerary.

Copy link
Contributor

@daniel-heppner-ibigroup daniel-heppner-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to have to check out what's going on with typescript here and why it's not giving an error for this

}
return stopCode || stopId?.split(":")[1] || stopId;
return stopCode || null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised you're not getting a type error from this. Null is not a valid return type from this function. I suggest using undefined instead, add it to the return type, and instead of using let stopCode just refactor the function to return from inside the if else blocks.

Also noting that using || is not safe with strings because "" is considered falsey and || checks for falsey. Use ?? instead which is actually checking for null or undefined only.

*/
export function getDisplayedStopId(placeOrStop: Place | Stop): string {
let stopId;
export function getDisplayedStopCode(placeOrStop: Place | Stop): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming this function is a breaking change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants