docs/scripts/buildApi.ts/updateStylesDefinition
async function updateStylesDefinition(context: {
  styles: ReactApi['styles'];
  component: { filename: string };
}) {
  const { styles, component } = context;

  const typesFilename = component.filename.replace(/\.js$/, '.d.ts');

  const unstyledFileName = getUnstyledFilename(typesFilename, true);

  try {
    // If the JSON file doesn't exists try extracting the info from the TS definition
    const typesSource = readFileSync(unstyledFileName, { encoding: 'utf8' });
    const typesAST = await babel.parseAsync(typesSource, {
      configFile: false,
      filename: unstyledFileName,
      presets: [require.resolve('@babel/preset-typescript')],
    });
    if (typesAST === null) {
      throw new Error('No AST returned from babel.');
    }

    // is not unstyled component
    if (typesFilename !== unstyledFileName) {
      styles.name = generateMuiName(path.parse(component.filename).name);
    }

    traverse(typesAST, {
      TSPropertySignature(babelPath) {
        const { node } = babelPath;
        const possiblyPropName = (node.key as babel.types.Identifier).name;
        if (possiblyPropName === 'classes' && node.typeAnnotation !== null) {
          const members = (node.typeAnnotation.typeAnnotation as babel.types.TSTypeLiteral).members;

          if (members) {
            styles.descriptions = {};
            members.forEach((member) => {
              const className = ((member as babel.types.TSPropertySignature)
                .key as babel.types.Identifier).name;
              styles.classes.push(className);
              if (member.leadingComments) {
                styles.descriptions[className] = trimComment(member.leadingComments[0].value);
              }
            });
          }
        }
      },
    });
  } catch (e) {
    // Do nothing as not every components has an unstyled version
  }
}