slint-ui/slint · warning

Unexpected FLOAT value type

Error message

Unexpected FLOAT value type: ${typeof value} for ${variable.name}

What it means

A Figma variable declared as FLOAT (numeric) resolved to a value whose runtime type is neither a number nor a resolvable reference. The exporter warns, and falls back to the default value for a length type (getDefaultValueForType("length")) instead of failing the export.

Solutions

  1. Fix the variable's alias in Figma so it points at a FLOAT variable (or set a raw numeric value)
  2. Re-resolve references/refresh the snapshot so value references are expanded before formatting
  3. Check earlier 'Failed to resolve FLOAT reference' warnings to find the root unresolved alias
  4. Loosen/verify the variable.resolvedType === "FLOAT" classification if the data is actually another type

Example fix

// before
console.warn(`Unexpected FLOAT value type: ${typeof value} ...`);
formattedValue = getDefaultValueForType("length");
// after
if (typeof value !== "number") {
  throw new Error(`FLOAT variable ${variable.name} has non-numeric value: ${JSON.stringify(value)}`);
}
formattedValue = formatNumber(value);
Defensive patterns

Strategy: type-guard

Validate before calling

if (variable.resolvedType === "FLOAT" && value !== null && typeof value !== "number" && typeof (value as any)?.id !== "string") {
  throw new Error(`FLOAT variable ${variable.name} has invalid value`);
}

Type guard

function isFloatValue(v: unknown): boolean {
  return typeof v === "number" || (typeof v === "object" && v !== null && typeof (v as any).id === "string");
}

Try / catch

try {
  formattedValue = formatFloat(value);
} catch (e) {
  exportInfo.errors.add(`FLOAT format failed for ${variable.name}: ${e.message}`);
  formattedValue = getDefaultValueForType("length");
}

Prevention

When it happens

Trigger: exportFigmaVariablesToSeparateFiles handles a FLOAT variable whose value is typeof neither 'number' nor a resolvable variable reference object (e.g. an alias that failed resolution earlier, or null/undefined).

Common situations: A FLOAT variable is aliased to a variable of another type whose resolution failed upstream; the Figma API returned an unexpected shape; the variable type was changed in Figma without re-resolving cached data.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/ea55ab315f2decfb. Report an issue: GitHub.

Appendix: source

Thrown at tools/figma-inspector/backend/utils/export-variables.ts:1129

                                if (resolvedValue) {
                                    formattedValue = resolvedValue;
                                    const referenceName =
                                        variableNamesById.get(value.id) ||
                                        value.id;
                                    comment = `Resolved from reference ${referenceName}`;
                                } else {
                                    formattedValue =
                                        getDefaultValueForType("length");
                                    const referenceName =
                                        variableNamesById.get(value.id) ||
                                        value.id;
                                    comment = `Failed to resolve reference ${referenceName}, using default`;
                                    exportInfo.warnings.add(
                                        `Failed to resolve FLOAT reference ${value.id} for ${variable.name}.${modeName}`,
                                    );
                                }
                            } else {
                                console.warn(
                                    `Unexpected FLOAT value type: ${typeof value} for ${variable.name}`,
                                );
                                formattedValue =
                                    getDefaultValueForType("length");
                            }
                        } else if (variable.resolvedType === "STRING") {
                            if (typeof value === "string") {
                                formattedValue = `"${value}"`;
                            } else if (
                                typeof value === "object" &&
                                value &&
                                "type" in value &&
                                value.type === "VARIABLE_ALIAS"
                            ) {
                                // Resolve reference to concrete value immediately
                                const resolvedValue =
                                    await followChainToConcreteValue(
                                        value.id,

View on GitHub (pinned to bb937076de)