7nohe / laravel-typegen

The library lets you generate TypeScript types from your Laravel code
79 stars 5 forks source link

Type generation for duplicate namespaces #39

Closed 7nohe closed 3 months ago

7nohe commented 3 months ago

Problem

If you define duplicate namespaces in Laravel’s routing files, the key will be duplicated in the type file generated by laravel-typegen.

web.php

Route::get('/dashboard1', DashboardController::class)->name('dashboard');
Route::get('/dashboard2', DashboardController::class)->name('dashboard');

param.ts

export type RouteParams = {
    "dashboard": {};
    "dashboard": {};
}

Solution

Ensure that a namespace (key) that has been used once during generation is not used again. If a duplicate is encountered, output a warning and skip it.