Coder Social home page Coder Social logo

laravel-typescript's People

Contributors

chancezeus avatar ekvedaras avatar jf908 avatar laravel-shift avatar lepikhinb avatar litiano avatar media253 avatar robmeijerink avatar xynnn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

laravel-typescript's Issues

SQLServer error when column type is "geography"

An error is thrown in the doctrine package, in AbstractPlatform if your table has a column type of "geography". My current workaround is to temporarily edit that file and have it return "string" instead of throwing an exception.

The documentation also fails to mention how you can actually use the "paths" in the config. Here is an example, to show how Spatie Permissions and the Laravel Database Notifications can be included when generating

    'paths' => [
        'Illuminate\Notifications\\' => 'vendor\laravel\framework\src\Illuminate\Notifications',
        'Spatie\Permission\Models\\' => 'vendor\spatie\laravel-permission\src\Models'
    ],

Submitting this issue so I can find this again next time I need to generate models and need to remember how to fix it.

Is this project abandoned?

This project is great but there's a few lingering issues and it doesn't seem like there's any activity?

I see there's been some small commits like 0ccde32 but no commenting on issues/prs?

tiny int map to boolean

laravel typescript version : dev-master
mysql column type is tiny int generated moduled.d.ts maped to boolean

Issue when try to generate typescript files

Hello seems awesome this package,
I'm trying to use but i have this error:

image

If i remove the ripcord package still have differentes class with "Cannot declare class XXX, because the name is already in use

Dependency issue when installing on Laravel 10

Hi,

I am trying to install this package on a Laravel 10.13.5 project but it throws some dependency issues:

 Problem 1
    - based/laravel-typescript[v0.0.1, ..., v0.0.2] require illuminate/contracts ^8.37 -> found illuminate/contracts[v8.37.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
    - based/laravel-typescript v0.0.3 requires illuminate/contracts ^8.37|^9.0 -> found illuminate/contracts[v8.37.0, ..., v8.83.27, v9.0.0, ..., v9.52.9] but these were not loaded, likely because it conflicts with another require.
    - Root composer.json requires based/laravel-typescript * -> satisfiable by based/laravel-typescript[v0.0.1, v0.0.2, v0.0.3].

You can also try re-running composer require with an explicit version constraint, e.g. "composer require based/laravel-typescript:*" to figure out if any version is installable, or "composer require based/laravel-typescript:^2.1" if you know which you need.

Is there something I can do to install the package?

Current project dependencies:

"require": {
    "php": "^8.1",
    "guzzlehttp/guzzle": "^7.2",
    "inertiajs/inertia-laravel": "^0.6.8",
    "laravel/framework": "^10.0",
    "laravel/sanctum": "^3.2",
    "laravel/tinker": "^2.8",
    "tightenco/ziggy": "^1.0"
  },
  "require-dev": {
    "fakerphp/faker": "^1.9.1",
    "laravel/breeze": "^1.20",
    "laravel/pint": "^1.8",
    "laravel/sail": "^1.18",
    "mockery/mockery": "^1.4.4",
    "nunomaduro/collision": "^7.0",
    "pestphp/pest": "^2.0",
    "pestphp/pest-plugin-laravel": "^2.0",
    "spatie/laravel-ignition": "^2.0",
    "spatie/laravel-web-tinker": "^1.8"
  },

Kind regards.

Laravel 9 support

Got the error during composer installation:

- Root composer.json requires based/laravel-typescript ^0.0.2 -> satisfiable by based/laravel-typescript[v0.0.2].
- based/laravel-typescript v0.0.2 requires illuminate/contracts ^8.37 -> found illuminate/contracts[v8.37.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another requ
ire.

Need support for illuminate/contracts v9

Cannot redeclare helpers when running php artisan typescript:generate

Getting strange behaviour when running php artisan typescript:generate it appears it's trying to redeclare all the helpers which are auto loaded via composer.json's "autoload" { "files" : [ "app/helpers.php"] }

$ php artisan typescript:generate
PHP Fatal error:  Cannot redeclare selectedVesselId() (previously declared in C:\www\workrest\app\helpers.php:25) in C:\www\workrest\app\Core\helpers.php on line 23

   Symfony\Component\ErrorHandler\Error\FatalError 

  Cannot redeclare selectedVesselId() (previously declared in C:\www\workrest\app\Core\helpers.php:25)

This is only occurring when running typescript:generate, other CLI commands for artisan are working fine e.g.:

$ php artisan cache:clear
Application cache cleared!

feat: generate interfaces from resources

Hi! What do you think about generation from Resources? e.g:

/**
 * @mixin \App\Models\Ticket
 */
class SupportResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request): array
    {
        return [
            'id'         => $this->id,
            'title'      => $this->title,
            'message'    => $this->message,
            'created_at' => $this->created_at->diffForHumans(),
            'category'   => [
                'title' => $this->category->short_title,
                'hex_color'   => $this->category->hex_color,
            ],
            'status'     => [
                'title'     => $this->status->title,
                'hex_color' => $this->status->hex_color,
            ],
        ];
    }
}

It's possible? If it is, it will be a consistent interface in the backend and frontend.

rule `present` in array items validation

Hi. First of all thanks for such a great package.

I've come accross issue

If i have request with the following rules

 return [
      'config' => ['required', 'array'],
      'config.*.key' => ['required', 'string'],
      'config.*.value' => ['present', 'nullable']
  ];

the result of transformation is

export interface ConfigUpdateRequest {
    config: Array<{
        key: string;
        value: present | null;
    }>;
}

which is incorrect because present is not typescript built-in type nor interface

Duplicate identifier for 'field'

If a field is a db relation, and you defined a getAttribute method for it to modify it's result, it gets added to the interface twice.

export interface User {
        id: number;
        first_name: string;
        last_name: string;
        email: string;
        last_session_id: string | null;
        password: string;
        remember_token: string | null;
        created_at: string | null;
        updated_at: string | null;
        active: boolean;
        roles?: Array<App.Role> | null;
        contact?: App.Contact | null;
        employee?: App.Employee | null;
        api_keys?: Array<App.OauthClient> | null;
        hidden_widgets?: Array<App.Widget> | null;
        seen_release_notes?: Array<App.ReleaseNote> | null;
        roles_count?: number | null;
        api_keys_count?: number | null;
        hidden_widgets_count?: number | null;
        seen_release_notes_count?: number | null;
        readonly roles?: any;
        readonly nice_name?: any;
        readonly agreed_to?: any;
        readonly widgets?: any;
        readonly tech_roles?: any;
        readonly metas?: any;
    }

I use getRolesAttribute and now have two roles keys there.

Enum support

Some of my models have enum fields.

This causes typescript:generate to throw:

Unknown database type enum requested, Doctrine\DBAL\Platforms\MariaDb1027Platform may not support it.

  at ___\vendor\doctrine\dbal\src\Platforms\AbstractPlatform.php:398

I'm not sure why it's not supported, as enums are working fine on my project/setup.

ENUM types Not Supported

 Doctrine\DBAL\Exception 

  Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL80Platform may not support it.

  at vendor/doctrine/dbal/src/Platforms/AbstractPlatform.php:441
    437438$dbType = strtolower($dbType);
    439440if (! isset($this->doctrineTypeMapping[$dbType])) {
  ➜ 441throw new Exception(
    442'Unknown database type ' . $dbType . ' requested, ' . static::class . ' may not support it.',
    443▕             );
    444▕         }
    445▕ 

      +8 vendor frames 
  9   [internal]:0
      Based\TypeScript\TypeScriptGenerator::Based\TypeScript\{closure}()

      +4 vendor frames 
  14  [internal]:0
      Based\TypeScript\TypeScriptGenerator::Based\TypeScript\{closure}()

Vetur Cannot find namespace 'App'.Vetur(2503)

Typescript, Vue 3 and my app are working well. But vetur is complaining

Cannot find namespace 'App'.Vetur(2503

Component.vue

<script lang="ts">
import { defineComponent, PropType } from "vue";

export default defineComponent({
    props: {
        product: {
            type: Object as PropType<App.Models.Product>,
            required: true
        }
    },
    setup() {

    }
});
</script>

Double Properties in same Generated Model interface

Hi there,

I'm encountering an issue with the properties of a generated Model in my project. The Model in question has a relationship with itself, representing a menu with parent and child elements within the same table. The parent property is functioning correctly, but there seems to be another property causing problems.

To help you diagnose the issue, here are the details you need:

<?php

namespace App\Infrastructure\Laravel\Models\AdministrationMenu;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\MediaLibrary\MediaCollections\Models\Concerns\HasUuid;

/**
 * App\Infrastructure\Laravel\Models\AdministrationMenu\AdministrationMenu
 *
 * @property int $id
 * @property string $uuid
 * @property string $name
 * @property string|null $url
 * @property string|null $icon_name
 * @property string|null $icon_path
 * @property string|null $permission
 * @property string|null $entity_name
 * @property mixed|null $parent_permissions
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \Illuminate\Database\Eloquent\Collection<int, AdministrationMenu> $children
 * @property-read int|null $children_count
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu query()
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereEntityName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereIconName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereIconPath($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereParent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereParentId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereParentPermissions($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu wherePermission($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereUrl($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereUuid($value)
 * @mixin \Eloquent
 * @noinspection PhpFullyQualifiedNameUsageInspection
 */
class AdministrationMenu extends Model
{
    use HasFactory, HasUuid;

    public function children(): HasMany
    {
        return $this->hasMany(AdministrationMenu::class, 'parent_id');
    }

    public function parent(): BelongsTo
    {
        return $this->belongsTo(AdministrationMenu::class, 'parent_id');
    }
}
```

```TS
declare namespace App.Infrastructure.Laravel.Models.AdministrationMenu {
    export interface AdministrationMenu {
        id: number;
        uuid: string;
        name: string;
        url: string | null;
        icon_name: string | null;
        icon_path: string | null;
        permission: string | null;
        parent_id: number | null;
        parent: boolean;
        entity_name: string | null;
        parent_permissions: Array<any> | any | null;
        created_at: string | null;
        updated_at: string | null;
        children?: Array<App.Infrastructure.Laravel.Models.AdministrationMenu.AdministrationMenu> | null;
        parent?: App.Infrastructure.Laravel.Models.AdministrationMenu.AdministrationMenu | null;
        children_count?: number | null;
    }

}
```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.