Skip to content

Commit

Permalink
Trying robot to convert more to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
cloke committed Oct 22, 2024
1 parent b0f4c6b commit e88de95
Show file tree
Hide file tree
Showing 14 changed files with 517 additions and 325 deletions.
7 changes: 1 addition & 6 deletions ember-apache-echarts/src/helpers/coalesce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import { helper } from '@ember/component/helper';
/**
* Returns the first non-null defined value from the positional parameters, or
* `undefined` if no non-null values were passed in.
*
* @param {array} positional - The positional parameters for this function
*
* @return {any} The first non-null defined element of `positional` or
* `undefined` if all the elements are null or undefined
*/
export default helper(function coalesce(positional) {
export default helper(function coalesce(positional: unknown[]): unknown {
return positional.find((param) => param != null);
});
12 changes: 2 additions & 10 deletions ember-apache-echarts/src/helpers/css-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@ import { helper } from '@ember/component/helper';

const numberRegEx = /^\d+$/;

const isNumeric = (value: unknown) =>
const isNumeric = (value: unknown): boolean =>
typeof value === 'number' || (typeof value === 'string' && value.match(numberRegEx) != null);

/**
* Formats a value so it can be used as a size in CSS expressions. Automatically
* uses `px` as the unit for nummeric values.
*
* @param {array} positional - The positional parameters for this function
* @param {string|number} positional[0] - The value to format as a CSS size
* @param {string|number} positional[1] - The default value if the value is null
* or undefined
*
* @return {string} The value formatted as a CSS size
*/

export default helper(function cssSize(positional: [string?, string?] /*, named*/): string {
export default helper(function cssSize(positional: [string?, string?]): string {
const size = positional[0] != null && positional[0] !== '' ? positional[0] : positional[1];

return isNumeric(size) || size === ''
Expand Down
Loading

0 comments on commit e88de95

Please sign in to comment.