perspective-dev/perspective · error · TypeError
TileSourceSpec. must be a positive number
Error message
TileSourceSpec.${key} must be a positive number What it means
The local helper num(key, dflt) inside parseTileSourceSpec validates optional numeric fields (tile_size, max_zoom): missing keys fall back to the default, but any present value must be a finite positive number. Zero, negative values, NaN, Infinity, or non-numbers (e.g. "256" as a string from JSON) trigger this TypeError.
Solutions
- Pass the field as a real number (tile_size: 256), not a numeric string
- Remove non-positive or non-finite values; omit the key to accept the documented default
- Coerce/validate JSON input with Number() before registering the spec
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/viewer-charts/src/ts/map/tile-source.ts:182 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of perspective-dev/perspective@11c8238c0c (2026-09-09).
Data as JSON: /api/errors/220bbeabb7146833.
Report an issue: GitHub.
Appendix: source
Thrown at packages/viewer-charts/src/ts/map/tile-source.ts:182
"TileSourceSpec.subdomains must be an array of non-empty strings",
);
}
const subdomains = Object.freeze([...rawSubdomains] as string[]);
if (template.includes("{s}") && subdomains.length === 0) {
throw new TypeError(
'TileSourceSpec.template uses "{s}" but no subdomains were given',
);
}
const num = (key: string, dflt: number): number => {
const v = raw[key];
if (v === undefined) {
return dflt;
}
if (typeof v !== "number" || !Number.isFinite(v) || v <= 0) {
throw new TypeError(
`TileSourceSpec.${key} must be a positive number`,
);
}
return v;
};
return Object.freeze({
id,
label,
template,
subdomains,
attribution,
tile_size: num("tile_size", 256),
max_zoom: num("max_zoom", 19),
});
}
View on GitHub (pinned to 11c8238c0c)