Skip to content

Commit 9dfa8ba

Browse files
Merge pull request #58 from laravel/pgsql-type-fix
Fix for PostgreSQL ID typing
2 parents 65536cc + 9059bc9 commit 9dfa8ba

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/Parameter.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,30 @@ protected function resolveTypes(): array
4646

4747
protected function typeToTypeScript($type)
4848
{
49-
return match ($type) {
50-
'int' => 'number',
51-
'integer' => 'number',
52-
'string' => 'string',
53-
'bool' => 'boolean',
54-
'boolean' => 'boolean',
55-
'bigint' => 'number',
56-
'number' => 'number',
57-
default => 'string',
58-
};
49+
$mapping = [
50+
'number' => [
51+
'int',
52+
'integer',
53+
'bigint',
54+
'int8',
55+
'serial',
56+
'bigserial',
57+
'bigint',
58+
'number',
59+
'float',
60+
'double',
61+
'decimal',
62+
],
63+
'string' => ['string', 'text', 'varchar', 'char', 'json', 'jsonb'],
64+
'boolean' => ['bool', 'boolean'],
65+
];
66+
67+
foreach ($mapping as $tsType => $types) {
68+
if (in_array($type, $types)) {
69+
return $tsType;
70+
}
71+
}
72+
73+
return 'string';
5974
}
6075
}

0 commit comments

Comments
 (0)