Skip to content

Commit

Permalink
✨ interface extensions seem to work better in ides
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjazz committed Jan 22, 2023
1 parent 24155c5 commit e4ff1a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Actions/GenerateCliOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ public function __invoke(Collection $models, bool $global = false): string

$plural = Str::plural($name);
$entry .= "{$this->indent}export type $plural = {$name}[]\n";
$entry .= "{$this->indent}export type {$name}Results = Modify<api.MetApiResults, { data: $plural }>\n\n";
$entry .= "{$this->indent}export type {$name}Modified = Modify<api.MetApiModified, { data: $name }>\n\n";
$entry .= "{$this->indent}export interface {$name}Results extends api.MetApiResults { data: $plural }\n";
$entry .= "{$this->indent}export interface {$name}MetApiData extends api.MetApiData { data: $name }\n";
$entry .= "{$this->indent}export interface {$name}Response extends MetApiResponse { data: {$name}MetApiData }\n\n";

$this->output .= $entry;
});
Expand Down
5 changes: 3 additions & 2 deletions src/ModelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ private function getCode(TypescriptInterface $interface): string
$code .= "{$this->space}}\n";
$plural = Str::plural($interface->name);
$code .= "{$this->space}export type $plural = {$interface->name}[]\n";
$code .= "{$this->space}export type {$interface->name}Results = Modify<api.MetApiResults, { data: $plural }>\n\n";
$code .= "{$this->space}export type {$interface->name}Modified = Modify<api.MetApiResponse, { data: {$interface->name} }>\n\n";
$code .= "{$this->space}export interface {$interface->name}Results extends api.MetApiResults { data: $plural }\n";
$code .= "{$this->space}export interface {$interface->name}MetApiData extends api.MetApiData { data: {$interface->name} }\n";
$code .= "{$this->space}export interface {$interface->name}Response extends MetApiResponse { data: {$interface->name}MetApiData }\n\n";

return $code;
}
Expand Down

0 comments on commit e4ff1a6

Please sign in to comment.