Improve type safety
Author: janbucharCreated Jul 22, 2025Updated Sep 18, 2026
Labelst-tooling
- There are multiple opportunities throughout Crawlee to improve type safety and optionally introduce runtime validation:
- Dataset items (
CrawlingContext.pushData) - Key-value store content
-
Request.userData— per-labeluserDatamap (#3747), opt-in standard-schema validation per label (#3851), default-route schema inference (#3919) - Request routing labels — typed labels (#3747), route map inferred on the crawler so
addRequests/enqueueLinksinputs are typed too (#3748) - ? possibly somewhere else
- Dataset items (
- One option is allowing the user to declare some special types (
DatasetItem,RequestLabel, ...) in a.d.tsfile and using it for type checking- TanStack router utilizes a similar approach
- A safer and more versatile approach would be to accept standard-schema models (either via
BasicCrawlerorConfiguration) and infer the types from those- this would also add runtime validation (in contrast to the
.d.tsapproach which is more of a gentleman agreement) - this is the approach the router part went with
- this would also add runtime validation (in contrast to the
Source: apify/crawlee