api-platform / api-platform/create-client

Typescript: DateTime properties are mapped to Date objects but they should be string

オープン
#131 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement TypeScript
主要言語
TypeScript
スター
376
フォーク
132
PR マージ指標
30日以内にマージされた PR はありません

説明

As the title says, the typescript interface generator maps the date/datetime/time types to Typescript's Date object (https://github.com/api-platform/client-generator/blob/master/src/generators/TypescriptInterfaceGenerator.js#L47).

However, API Platform by default serializes DateTime objects as ISO 8601 strings, so we should change the type to `string` I think, otherwise we will run into all sorts of typescript errors when trying to use the date string (which the TS compiler would see as a Date object).

I could do a PR with the change from Date to string, however I have another question: Can the user change how PHP DateTimeInterface is serialized by Api Platform (i.e. from string to timestamp)? If so, how could we tell this to the client generator?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。