The schema.org node to inspect.
The declared types as strings; [] when @type is missing.
typeList({ '@type': 'Product' }); // ['Product']
typeList({ '@type': ['Book', 'Product'] }); // ['Book', 'Product']
typeList({ name: 'untyped' }); // []
export function typeList(node: JsonObject): string[] {
return toArray(node['@type']).filter((t): t is string => typeof t === 'string');
}
Read a node's
@typeas a string array. An item may declare several types at once (schema.org uses multiple inheritance — something can be both aBookand aProduct), and@typemay be absent, so this always returns an array.