slint-ui/slint · warning
Unexpected STRING value type
Error message
Unexpected STRING value type: ${typeof value} for ${variable.name} What it means
A Figma variable declared as STRING resolved to a value that is not a string nor a resolvable string reference. The exporter warns and substitutes the default value for a string type instead of failing.
Solutions
- Fix the alias in Figma so the STRING variable references a string variable or holds a literal string
- Refresh/re-resolve the variables snapshot so references are expanded before formatting
- Trace earlier 'Failed to resolve STRING reference' warnings to the unresolved alias
- Validate variable.resolvedType classification against the actual Figma type
Example fix
// before
formattedValue = getDefaultValueForType("string");
// after
if (typeof value !== "string") {
exportInfo.errors.add(`STRING variable ${variable.name} has non-string value`);
formattedValue = ""; // or throw, depending on strictness
} Defensive patterns
Strategy: type-guard
Validate before calling
if (variable.resolvedType === "STRING" && value !== null && typeof value !== "string" && typeof (value as any)?.id !== "string") {
throw new Error(`STRING variable ${variable.name} has invalid value`);
} Type guard
function isStringValue(v: unknown): boolean {
return typeof v === "string" || (typeof v === "object" && v !== null && typeof (v as any).id === "string");
} Try / catch
try {
formattedValue = formatString(value);
} catch (e) {
exportInfo.errors.add(`STRING format failed for ${variable.name}: ${e.message}`);
formattedValue = getDefaultValueForType("string");
} Prevention
- Resolve aliases before formatting string values
- Validate value types against resolvedType in a pre-export pass
- Refresh the snapshot whenever variable types change in Figma
When it happens
Trigger: exportFigmaVariablesToSeparateFiles handles a STRING variable whose value is typeof neither 'string' nor an expandable reference object (e.g. alias to a non-string variable, null, undefined).
Common situations: String variable aliased to a color/float variable whose resolution failed; Figma API shape change; stale cached resolved data after the variable type changed in Figma.
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
- Unexpected BOOLEAN value type
- Unexpected FLOAT value type
- Missing resolved data for
- [getVariablePathString] Collection not found for variable ID
- Mode mismatch for variable
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/2d26f1d64a2c5083.
Report an issue: GitHub.
Appendix: source
Thrown at tools/figma-inspector/backend/utils/export-variables.ts:1168
if (resolvedValue) {
formattedValue = resolvedValue;
const referenceName =
variableNamesById.get(value.id) ||
value.id;
comment = `Resolved from reference ${referenceName}`;
} else {
formattedValue =
getDefaultValueForType("string");
const referenceName =
variableNamesById.get(value.id) ||
value.id;
comment = `Failed to resolve reference ${referenceName}, using default`;
exportInfo.warnings.add(
`Failed to resolve STRING reference ${value.id} for ${variable.name}.${modeName}`,
);
}
} else {
console.warn(
`Unexpected STRING value type: ${typeof value} for ${variable.name}`,
);
formattedValue =
getDefaultValueForType("string");
}
} else if (variable.resolvedType === "BOOLEAN") {
if (typeof value === "boolean") {
formattedValue = value ? "true" : "false";
} 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)