Skip to content

Instantly share code, notes, and snippets.

@avaly
Last active November 17, 2023 13:55
Show Gist options
  • Save avaly/770d08f6321586002e3c7492813b4dfe to your computer and use it in GitHub Desktop.
Save avaly/770d08f6321586002e3c7492813b4dfe to your computer and use it in GitHub Desktop.
prettier-experimental-ternaries-samples.ts
// Having the condition start on a newline is not readable
const availabilityStartDate =
availability.startDate ? DateTime.fromJSDate(availability.startDate, { zone: 'utc' }) : DateTime.now().toUTC();
// Previously it was much more readable:
const availabilityStartDate = availability.startDate
? DateTime.fromJSDate(availability.startDate, { zone: "utc" })
: DateTime.now().toUTC();
/////////////////////////////////////////////////////////////
// The wrapping parenthesis are in a weird position
const columns = (
definition.length > 1 && typeof definition[1] === 'object' ?
definition[0]
: definition) as PGIndexElement<TDocument>[];
// Previously it was much more readable:
const columns = (
definition.length > 1 && typeof definition[1] === 'object' ? definition[0] : definition
) as PGIndexElement<TDocument>[];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment