private buildOverridesDeclaration()

in packages/codegen-ui-react/lib/react-studio-template-renderer.ts [842:889]


  private buildOverridesDeclaration(hasVariants: boolean): VariableStatement {
    if (hasVariants) {
      this.importCollection.addMappedImport(ImportValue.GET_OVERRIDES_FROM_VARIANTS);
      this.importCollection.addMappedImport(ImportValue.VARIANT);

      return factory.createVariableStatement(
        undefined,
        factory.createVariableDeclarationList(
          [
            factory.createVariableDeclaration(
              factory.createIdentifier('overrides'),
              undefined,
              undefined,
              factory.createCallExpression(factory.createIdentifier('mergeVariantsAndOverrides'), undefined, [
                factory.createCallExpression(factory.createIdentifier('getOverridesFromVariants'), undefined, [
                  factory.createIdentifier('variants'),
                  factory.createIdentifier('props'),
                ]),
                factory.createBinaryExpression(
                  factory.createIdentifier('overridesProp'),
                  factory.createToken(ts.SyntaxKind.BarBarToken),
                  factory.createObjectLiteralExpression([], false),
                ),
              ]),
            ),
          ],
          ts.NodeFlags.Const,
        ),
      );
    }

    return factory.createVariableStatement(
      undefined,
      factory.createVariableDeclarationList(
        [
          factory.createVariableDeclaration(
            factory.createIdentifier('overrides'),
            undefined,
            undefined,
            factory.createObjectLiteralExpression([
              factory.createSpreadAssignment(factory.createIdentifier('overridesProp')),
            ]),
          ),
        ],
        ts.NodeFlags.Const,
      ),
    );
  }