-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typescript-angular: type difference between date and date-time #4170
Comments
a |
format: date-time
is generated as Date
intypescript-angular
and not as string
(as ormat: date
is)
I agree, it should be string. However, that could lead to "breaking" changes in typescript being used today (which is admittedly better than the current case, where you could run into runtime bugs). The main drawback I see, however, is that you loose the 'documentation' given by the "Date" type. Right now, if I get a Date in the generated typescript. I know that I can parse that string into a JS date, which can be helpful. |
Hi, well I'm fine with both being string or date(I prefere strings though) but it should be consistent, which is not now :(
I'm sorry, but I don't understand what you mean? |
since there is still the possibility to supply the type-mapping option, I would change it to string for both, date and date-time. |
@macjohnny Might try to. But if you guys know its 5 mins job for ya, go for it. It might take hours for me. But yeah, will try.. |
@skorunka I can point you to the right files to change |
I think the source is here: Lines 124 to 125 in c32fa5d
a custom type mapping should be added here: Line 76 in c32fa5d
then simply run
and commit the changed samples in the |
@macjohnny I suggest putting this in the settings. I do not agree that the date should be just a string. In the project that I am developing, the date is transmitted in ISO format (ex 2019-12-26T14:46:56+00:00 - date or 2019-12-26T14:46:56Z - date time) and this standard is used a lot. The option that you offer will result in the parameter having the date format specified by the locale (this is never ISO in js / ts). I came here just because date is generated as a string ... |
PR for fix #4869 |
Date is converted to json by JSON.stringify(...) function, when you convert a date from I think |
Yaml:
is generated for
typescript-angular
as:dateAndTime?: Date;
Yaml:
is generated for
typescript-angular
as:date?: sring;
Why is there difference?
Why is not
date-time
generated asstring
?Thnx.
The text was updated successfully, but these errors were encountered: