Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Typescriptable Laravel Package

kiwilan/laravel-typescriptable

Generate TypeScript types from your Laravel models, resources, and form requests, keeping frontend and backend in sync with automatically updated type definitions and minimal configuration.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • The package is a compile-time code-generation bridge, not a runtime dependency: it reads Laravel-side sources (Eloquent models, route definitions, Spatie Settings classes) and emits static TypeScript declarations. This is a unidirectional Laravel → TypeScript contract with no request-path coupling, which is the right shape for an Inertia/Vue/React SPA backed by a Laravel monolith.
  • Fits well where the frontend and backend ship from the same repo or the same release train, since the artifact is just files that get type-checked by tsc.
  • Poor fit for API-only backends with external or third-party consumers — those need a language-agnostic contract (OpenAPI/JSON Schema), and a TypeScript-only generator would create a one-client contract that drifts from reality for everyone else.
  • Overlap risk: the route-typing portion competes with Ziggy typings and Laravel Wayfinder, and the model-typing portion competes with spatie/laravel-typescript-transformer. The differentiator is the combined surface (models + routes + settings) and the optional NPM/Inertia package; that is a convenience win, not a moat.

Integration feasibility

  • Low-ceremony adoption: composer require, publish config, run an artisan generation command, commit or emit the output. No middleware, no service provider wiring in the request lifecycle.
  • The main friction is that accurate model typing generally requires schema knowledge — either live DB introspection or migration/reflection analysis. That makes generation dependent on a reachable database or a correctly configured connection in CI and container builds, which is where most integration projects stall.
  • The optional NPM package is purely additive; the core value is realized without it.

Technical risk

  • Type fidelity is the dominant technical risk: Eloquent casts, custom cast classes, accessors/mutators, enum casts, $appends, JSON columns, nullable columns, and relationship attributes are all places where a generator can emit a plausible-but-wrong type. Wrong types are worse than no types because they produce false confidence at compile time.
  • DB-driver variance: MySQL/Postgres/SQLite map column types differently; a generator that introspects the schema can emit different TypeScript depending on which connection ran it. Output should be deterministic and driver-stable, or generated against a canonical schema.
  • Bus factor: 39 stars and effectively a single maintainer. MIT licensing and a small surface area make forking viable, but there is no support contract, no security review process, and no guarantee of timely fixes for a new Laravel major.
  • Adjacent commoditization: first-party route typing (Wayfinder) and the incumbent Spatie transformer are both actively developed; this package's surface could be partially absorbed, stranding the integration.

Key questions

  1. What is the supported PHP/Laravel version matrix, and how quickly are new Laravel majors adopted?
  2. How are model property types derived — live DB introspection, migrations, reflection, or a mix? Is a DB connection mandatory for generation?
  3. Are casts, enum casts, accessors, $appends, and relationships typed correctly, and how are ambiguous/unknown types handled (fail, any, unknown)?
  4. Is the output deterministic (stable ordering, no timestamps/hashes) so CI can diff it for drift?
  5. What is the SemVer policy — can a minor release change emitted type shapes?
  6. What happens when generation fails partway: does it leave stale files, partial files, or abort cleanly?
  7. Does it support multiple DB connections and multi-tenant schemas?
  8. How does it coexist with Ziggy/Wayfinder if the team already has route typing?

Integration Approach

Stack fit

  • Target profile: Laravel 10/11/12 monolith, PHP 8.2+, Inertia + Vue 3 or React with TypeScript 5.x, Vite build.
  • Confirm version compatibility against whatever Spatie Settings major is in use — that dependency is the most likely to pin the package out of an upgrade.
  • If Ziggy or Wayfinder is already present, scope this package to models and settings only and leave route typing where it is; otherwise you get two competing sources of truth for route names and params.

Migration path

  • Run as a side-by-side generator first: emit .d.ts files into a dedicated directory (e.g. resources/js/types/generated/) and leave hand-written interfaces untouched. Nothing breaks if the experiment is abandoned.
  • Convert one bounded domain module at a time, deleting the corresponding hand-written interfaces as each generated set is proven correct by tsc --noEmit in CI.
  • Keep a thin hand-written layer for view-model shapes that do not map 1:1 to Eloquent models; do not try to force generated types to cover composed UI state.

Compatibility

  • Decide up front whether generated output is committed to VCS or produced at build time. Committed output gives reviewable diffs and no DB dependency in the frontend build; build-time output avoids merge noise but requires DB access in every CI job.
  • Exclude generated directories from ESLint/Prettier autofix (or run the project formatter on them deterministically) so formatting churn doesn't mask real type changes.
  • Pin the Composer version exactly and treat upgrades as reviewed changes — a minor bump can silently alter emitted types.

Sequencing

  1. Spike on a branch: generate for a single 5–10 model module, verify types against actual API responses.
  2. Validate the risky cases explicitly: nullable columns, enum casts, JSON columns, accessors, $appends.
  3. Add a composer types:generate script and a CI job that regenerates and fails on a non-empty diff (drift gate).
  4. Expand domain by domain; delete duplicated hand-written interfaces as each is replaced.
  5. Add routes and settings only if the first two phases proved stable.
  6. Document ownership: who regenerates, who reviews generated diffs, and the upgrade runbook.

Operational Impact

Maintenance

  • Ongoing cost is low but non-zero: regeneration must be wired into the change flow (post-migration, post-model-change), and the drift gate must be enforced or types will silently rot.
  • Requires an owner. Generated-code directories with no owner become stale and eventually misleading.
  • Upstream tracking is a real task given the release cadence and single maintainer; budget a review per Laravel major and per package minor.

Support

  • Community-only, no SLA, no vendor. Mitigations: pin versions, keep the integration surface narrow (config + one artisan command + one output directory), and confirm the fork path is viable before committing — MIT plus a small codebase makes an internal fork or a switch to the Spatie transformer a realistic exit.
  • Have a documented fallback: if the package is abandoned, revert to hand-written interfaces for the affected modules, or replace only the model layer with spatie/laravel-typescript-transformer.

Scaling

  • Generation time and output size grow linearly with model count; fine for tens to low hundreds of models. Very large monoliths or multi-tenant schema variants may need per-module or per-connection configuration, and generation could become a slow CI step.
  • Frontend type-check time grows with the emitted declaration volume; keep generated files out of unrelated tsconfig projects.
  • The DB dependency at generation time is the scaling bottleneck in CI — parallel or containerized builds need a reachable, migrated database, or a pre-generated committed artifact.

Failure modes

  • Silent drift: stale generated types still compile but no longer match the API. The most dangerous failure; mitigated only by a CI regeneration diff gate.
  • Generation crash: blocks CI if generated output is required for the build. Ensure the script fails loudly and does not leave partial files.
  • Driver mismatch: generating against SQLite locally and MySQL in CI yields divergent types.
  • Route param drift: controller signature changes not reflected in emitted route types, producing runtime 404s the compiler approved.
  • SemVer surprise: a minor upgrade changes type shapes and breaks the frontend build mid-sprint.
  • Upstream abandonment: no fix for a new Laravel major; forces fork or replacement on someone else's schedule.

Ramp-up

  • Backend: roughly half a day for a Laravel developer to install, configure, and generate the first module; the real time is spent validating type fidelity, not setup.
  • Frontend: near-zero — developers consume the types through normal imports. The behavioral change to communicate is that model interfaces are now generated and must not be hand-edited.
  • Team-wide: one short doc covering the regeneration command, the drift gate, and the "don't edit generated files" rule is sufficient.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel