Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Convert time-format to TypeScript #78

Merged
merged 6 commits into from
Jan 25, 2019
Merged

Convert time-format to TypeScript #78

merged 6 commits into from
Jan 25, 2019

Conversation

kristw
Copy link
Contributor

@kristw kristw commented Jan 22, 2019

🏆 Enhancements

  • Convert @superset-ui/time-format to TypeScript

💔 Breaking Changes

  • BREAKING CHANGE: Make formatter always returns string. This is different from previous behavior.
Value formatted value (before) formatted value (after)
null null 'null'
undefined undefined 'undefined'
NaN NaN 'NaN'

@kristw kristw requested a review from a team as a code owner January 22, 2019 22:25
@kristw kristw added the reviewable Ready for review label Jan 22, 2019
@kristw kristw force-pushed the kristw--time-format-ts branch from bfff978 to 7a73161 Compare January 23, 2019 18:26
@codecov
Copy link

codecov bot commented Jan 23, 2019

Codecov Report

Merging #78 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #78   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          68     68           
  Lines         754    774   +20     
  Branches      150    182   +32     
=====================================
+ Hits          754    774   +20
Impacted Files Coverage Δ
...-time-format/src/TimeFormatterRegistrySingleton.ts 100% <ø> (ø)
...-ui-time-format/src/formatters/smartDateVerbose.ts 100% <ø> (ø)
...uperset-ui-time-format/src/formatters/smartDate.ts 100% <ø> (ø)
...ackages/superset-ui-time-format/src/TimeFormats.ts 100% <ø> (ø)
...kages/superset-ui-time-format/src/TimeFormatter.ts 100% <100%> (ø)
...perset-ui-time-format/src/TimeFormatterRegistry.ts 100% <100%> (ø)
...time-format/src/factories/createD3TimeFormatter.ts 100% <100%> (ø)
packages/superset-ui-time-format/src/utils.ts 100% <100%> (ø)
...-time-format/src/factories/createMultiFormatter.ts 100% <100%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c353610...41c27e3. Read the comment docs.

@kristw kristw force-pushed the kristw--time-format-ts branch from 7a73161 to 8287ef4 Compare January 23, 2019 18:49
@mistercrunch
Copy link
Contributor

Are we sure there are no truthy evaluation of what comes out of this function in the Superset codebase? Wouldn't it be safer to either return either null or a string, or an falsy empty string?

@kristw
Copy link
Contributor Author

kristw commented Jan 24, 2019

My understanding of what @mistercrunch means is when people do sth like

formatTime(time, 'formatString') || 'custom label when null or undefined'

This will work if the formatTime() function returns truthy/falsy. My rationale for making it string was to make the function complete in itself without relying on || 'fallback'. If dev want to manually handle labels for null or undefined then they can add stricter check before calling formatTime().

Copy link
Contributor

@williaster williaster left a comment

Choose a reason for hiding this comment

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

overall looks good to me. had one thought about .ts + .js test files vs @ts-ignore.

I also generally think that the coercion of null to a string is okay. I think it's messy/not strict enough to have instances of timeFormatter(blah) || 'fallback blah', devs should check blah themselves IMO. This could be easily changed to (blah && timeFormatter(blah)) || 'fallback'.

@xtinec might still have some thoughts.

@kristw kristw force-pushed the kristw--time-format-ts branch from 8287ef4 to 41c27e3 Compare January 24, 2019 21:36
@kristw kristw merged commit 727618b into master Jan 25, 2019
@delete-merged-branch delete-merged-branch bot deleted the kristw--time-format-ts branch January 25, 2019 21:28
@kristw kristw added this to the v0.9.0 milestone Feb 1, 2019
kristw added a commit that referenced this pull request Apr 17, 2020
Squashed commits:
[23ad0d6] feat: working box plot
[a7ed565] fix: typings
[57a62b7] feat: clarify horizontal/vertical mode
[6312737] fix: typings
[2734de3] feat: box plot types
[cb3c239] fix: typings
[7e2dcda] feat: add box plot
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants