ziggy icon indicating copy to clipboard operation
ziggy copied to clipboard

Generated TS file doesn't specify if a param is optional

Open alexmccabe opened this issue 1 year ago • 3 comments

Description

The generated TS file marks all params as optional, where really only routes containing ? should be marked as optional in the generated types.

Suggestion

Line 68 of index.d.ts marks every param as optional. It looks like it should be possible to know whether a route contains a question mark during the generating process.

Alternatives

I tried some complicated extraction technique combining the generated TS file and the generated ziggy file, however that depends on the generated ziggy file being a ts file also, with the object set to as const.

alexmccabe avatar Nov 02 '23 17:11 alexmccabe

Yeah it would definitely be possible to include this info in the generated .d.ts file, I played around with it at one point.

bakerkretzmar avatar Nov 02 '23 19:11 bakerkretzmar

@bakerkretzmar that would be awesome, do you have any code to share? I'd be happy to open a PR if there is a base I can work from

alexmccabe avatar Nov 15 '23 09:11 alexmccabe

I've opened a PR for this request #697

alexmccabe avatar Dec 18 '23 11:12 alexmccabe