Skip to content

Commit

Permalink
fix(types): adding missing format helpers (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanksdesign authored Jan 3, 2023
1 parent 251df97 commit a6f4b34
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/common/formatHelpers/getTypeScriptType.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const { unique } = require('../../utils/es6_');
* }).join('\n');
* }
* });
*```
*```
* @param {*} value A value to check the type of.
* @return {String} A valid name for a TypeScript type.
*
*/
function getTypeScriptType(value) {
function getTypeScriptType(value) {
if (Array.isArray(value)) return getArrayType(value)
if (typeof value === 'object') return getObjectType(value)
if (['string', 'number', 'boolean'].includes(typeof value)) return typeof value
Expand Down
2 changes: 1 addition & 1 deletion lib/common/formatHelpers/iconsWithPrefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* });
* ```
*/
function iconsWithPrefix(prefix, allTokens, options) {
function iconsWithPrefix(prefix, allTokens, options) {
return allTokens.filter(function(token) {
return token.attributes.category === 'content' && token.attributes.type === 'icon';
})
Expand Down
2 changes: 1 addition & 1 deletion lib/common/formatHelpers/minifyDictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* });
* ```
*/
function minifyDictionary(obj) {
function minifyDictionary(obj) {
if (typeof obj !== 'object' || Array.isArray(obj)) {
return obj;
}
Expand Down
7 changes: 7 additions & 0 deletions types/FormatHelpers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

import { Dictionary } from './Dictionary';
import { DesignToken } from './DesignToken';
import { TransformedToken } from './TransformedToken';
import { File } from './File';

Expand Down Expand Up @@ -56,4 +57,10 @@ export interface FormatHelpers {
) => (token: TransformedToken) => string;
fileHeader: (args: FileHeaderArgs) => string;
formattedVariables: (args: FormattedVariablesArgs) => string;
minifyDictionary: (dictionary: object) => object;
getTypeScriptType: (value: unknown) => string;
iconsWithPrefix: (prefix: string, allTokens: DesignToken[], options: object) => string;
sortByReference: (dictionary: Dictionary) => string;
sortByName: (a: DesignToken, b: DesignToken) => number;
setSwiftFileProperties: (options: object, objectType: string, transformGroup: string) => string;
}

0 comments on commit a6f4b34

Please sign in to comment.