|
1 | 1 | @include('wayfinder::docblock')
|
2 |
| -{!! when(($export ?? true) && !$isInvokable, 'export ') !!}const {!! $method !!} = (@include('wayfinder::function-arguments')): { |
3 |
| - url: string, |
4 |
| - method: @js($verbs->first()->actual), |
5 |
| -} => ({ |
| 2 | +{!! when(($export ?? true) && !$isInvokable, 'export ') !!}const {!! $method !!} = (@include('wayfinder::function-arguments')): RouteDefinition<@js($verbs->first()->actual)> => ({ |
6 | 3 | url: {!! $method !!}.url({!! when($parameters->isNotEmpty(), 'args, ') !!}options),
|
7 | 4 | method: @js($verbs->first()->actual),
|
8 | 5 | })
|
9 | 6 |
|
| 7 | +@php |
| 8 | + $verbsArray = $verbs->map(fn($verb) => $verb->actual)->join("','"); |
| 9 | +@endphp |
| 10 | + |
10 | 11 | {!! $method !!}.definition = {
|
11 |
| - methods: [@foreach ($verbs as $verb)@js($verb->actual){!! when(! $loop->last, ',') !!}@endforeach], |
| 12 | + methods: ['{!! $verbsArray !!}'], |
12 | 13 | url: {!! $uri !!},
|
13 |
| -} |
| 14 | +} satisfies RouteDefinition<['{!! $verbsArray !!}']> |
14 | 15 |
|
15 | 16 | @include('wayfinder::docblock')
|
16 | 17 | {!! $method !!}.url = (@include('wayfinder::function-arguments')) => {
|
|
69 | 70 |
|
70 | 71 | @foreach ($verbs as $verb)
|
71 | 72 | @include('wayfinder::docblock')
|
72 |
| -{!! $method !!}.{!! $verb->actual !!} = (@include('wayfinder::function-arguments')): { |
73 |
| - url: string, |
74 |
| - method: @js($verb->actual), |
75 |
| -} => ({ |
| 73 | +{!! $method !!}.{!! $verb->actual !!} = (@include('wayfinder::function-arguments')): RouteDefinition<@js($verb->actual)> => ({ |
76 | 74 | url: {!! $method !!}.url({!! when($parameters->isNotEmpty(), 'args, ') !!}options),
|
77 | 75 | method: @js($verb->actual),
|
78 | 76 | })
|
79 | 77 | @endforeach
|
80 | 78 |
|
81 | 79 | @if ($withForm)
|
82 | 80 | @include('wayfinder::docblock')
|
83 |
| - const {!! $method !!}Form = (@include('wayfinder::function-arguments')): { |
84 |
| - action: string, |
85 |
| - method: @js($verbs->first()->formSafe), |
86 |
| - } => ({ |
| 81 | + const {!! $method !!}Form = (@include('wayfinder::function-arguments')): RouteFormDefinition<@js($verbs->first()->formSafe)> => ({ |
87 | 82 | action: {!! $method !!}.url(
|
88 | 83 | {!! when($parameters->isNotEmpty(), 'args, ') !!}
|
89 | 84 | @if ($verbs->first()->formSafe === $verbs->first()->actual)
|
|
102 | 97 |
|
103 | 98 | @foreach ($verbs as $verb)
|
104 | 99 | @include('wayfinder::docblock')
|
105 |
| - {!! $method !!}Form.{!! $verb->actual !!} = (@include('wayfinder::function-arguments')): { |
106 |
| - action: string, |
107 |
| - method: @js($verb->formSafe), |
108 |
| - } => ({ |
| 100 | + {!! $method !!}Form.{!! $verb->actual !!} = (@include('wayfinder::function-arguments')): RouteFormDefinition<@js($verb->formSafe)> => ({ |
109 | 101 | action: {!! $method !!}.url(
|
110 | 102 | {!! when($parameters->isNotEmpty(), 'args, ') !!}
|
111 | 103 | @if ($verb->formSafe === $verb->actual)
|
|
0 commit comments