JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 488
  • Score
    100M100P100Q97723F
  • License MIT

The library lets you generate TypeScript types from your Laravel models.

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@7nohe/laravel-typegen) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Laravel Typegen

    Features

    • Generate TypeScript types from Laravel models
    • Support Relationhips
    • Support Enum (from PHP8.1)

    Installation

    $ npm install -D @7nohe/laravel-typegen

    Usage

    Edit package.json

    {
        "scripts": {
            "typegen": "laravel-typegen"
        },
    }
    $ npm run typegen

    Available options

    Usage: laravel-typegen [options]
    
    Generate TypeScript types from your Laravel models
    
    Options:
      -V, --version         output the version number
      -o, --output <value>  Output directory (default: "resources/ts/types")
      --laravel-enum        Use Laravel Enum (default: false)
      --enum-path <value>   Path to enum files (default: "app/Enums")
      -h, --help            display help for command

    Laravel Enum Support

    If you use (Laravel Enum)[https://github.com/BenSampo/laravel-enum], use the option --laravel-enum.

    {
        "scripts": {
            "typegen": "laravel-typegen --laravel-enum"
        },
    }

    Development

    Setup example project

    $ cd examples/laravel9-app
    $ cp .env.example .env
    $ docker run --rm \
        -u "$(id -u):$(id -g)" \
        -v "$(pwd):/var/www/html" \
        -w /var/www/html \
        laravelsail/php81-composer:latest \
        composer install --ignore-platform-reqs
    $ ./vendor/bin/sail up -d
    $ ./vendor/bin/sail php artisan key:generate
    $ ./vendor/bin/sail php artisan migrate --seed
    $ ./vendor/bin/sail npm install

    Debug

    $ pnpm install
    $ sh debug.sh