You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/11/05 22:18:29 UTC

[GitHub] [superset] Damans227 commented on a change in pull request #17361: chore: migrate FormattedNumber component from jsx to tsx

Damans227 commented on a change in pull request #17361:
URL: https://github.com/apache/superset/pull/17361#discussion_r744004831



##########
File path: superset-frontend/src/visualizations/TimeTable/FormattedNumber.tsx
##########
@@ -17,27 +17,23 @@
  * under the License.
  */
 import React from 'react';
-import PropTypes from 'prop-types';
 import { formatNumber } from '@superset-ui/core';
 
-const propTypes = {
-  num: PropTypes.number,
-  format: PropTypes.string,
-};
-
-const defaultProps = {
-  num: 0,
-  format: undefined,
-};
+interface FormattedNumberProps {
+  num?: string | number;
+  format?: string;
+}
 
-function FormattedNumber({ num, format }) {
+function FormattedNumber({
+  num = 0,
+  format = undefined,
+}: FormattedNumberProps) {
   if (format) {
-    return <span title={num}>{formatNumber(format, num)}</span>;
+    return (
+      <span title={num as string}>{formatNumber(format, num as number)}</span>

Review comment:
       > it looks like `formatNumber` might actually support strings already (according to the old code). could you check the function in superset-ui and see if that type needs to be changed?
   
   Sure thing. 
   
   > also, for `title`, let's do `` title={`${num}`} `` instead asserting and overriding the type
   
   Will do. 
   
   

##########
File path: superset-frontend/src/visualizations/TimeTable/FormattedNumber.tsx
##########
@@ -17,27 +17,23 @@
  * under the License.
  */
 import React from 'react';
-import PropTypes from 'prop-types';
 import { formatNumber } from '@superset-ui/core';
 
-const propTypes = {
-  num: PropTypes.number,
-  format: PropTypes.string,
-};
-
-const defaultProps = {
-  num: 0,
-  format: undefined,
-};
+interface FormattedNumberProps {
+  num?: string | number;
+  format?: string;
+}
 
-function FormattedNumber({ num, format }) {
+function FormattedNumber({
+  num = 0,
+  format = undefined,

Review comment:
       Yea, that makes sense!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org