#3082·crawlee

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-label userData map (#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 / enqueueLinks inputs are typed too (#3748)
    • ? possibly somewhere else
  • One option is allowing the user to declare some special types (DatasetItem, RequestLabel, ...) in a .d.ts file and using it for type checking
  • A safer and more versatile approach would be to accept standard-schema models (either via BasicCrawler or Configuration) and infer the types from those
    • this would also add runtime validation (in contrast to the .d.ts approach which is more of a gentleman agreement)
    • this is the approach the router part went with