All files / packages/design-tokens/src/style-dictionary/utils flat-type-map.ts

100% Statements 5/5
83.33% Branches 5/6
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23          3x                   3x 20x 2x     18x    
export type FlatTypeInfo = {
  type: string;
  syntax?: string;
};
 
const FLAT_TYPE_MAP: Record<string, FlatTypeInfo> = {
  dimension: { type: 'dimension', syntax: '<length>' },
  duration: { type: 'duration', syntax: '<time>' },
  number: { type: 'number', syntax: '<number>' },
  color: { type: 'color', syntax: '<color>' },
  string: { type: 'string' },
  shadow: { type: 'shadow' },
  fontFamily: { type: 'fontFamily' },
};
 
export const getFlatTypeInfo = (dtcgType: unknown): FlatTypeInfo => {
  if (typeof dtcgType !== 'string' || !dtcgType) {
    return { type: 'unknown' };
  }
 
  return FLAT_TYPE_MAP[dtcgType] ?? { type: dtcgType };
};