tkrajina / typescriptify-golang-structs

A Golang struct to TypeScript class/interface converter
Apache License 2.0
505 stars 87 forks source link

time.Time no longer automatically converted to Date #43

Closed AntiPaste closed 3 years ago

AntiPaste commented 3 years ago

The README states that This is how now time.Time is managed in the library by default. which was true as of commit c68aad549d37f1a309a7e5cf3762a59c6ce04ae5:

// manage time.Time automatically
result = result.ManageType(time.Time{}, "Date", "new Date(__VALUE__)")

However as of commit a7a821d78f8f6615f190e002c4565d7a38a49233 this seems to be missing.

Can this functionality be restored or should the README be corrected?

tkrajina commented 3 years ago

Hm, just a moment, the README says:

converter := New()
converter.ManageType(time.Time{}, TypeOptions{TSType: "Date", TSTransform: "new Date(__VALUE__)"})

not:

result = result.ManageType(time.Time{}, "Date", "new Date(__VALUE__)")

Also, there is a test for this ManageType in https://github.com/tkrajina/typescriptify-golang-structs/blob/master/typescriptify/typescriptify_test.go#L369

Am I missing something?

AntiPaste commented 3 years ago

Sorry, let me rephrase.

Previously the library had code to handle time.Time conversion to Javascript Date automatically (see here). This meant that time.Time was automatically converted to Javascript Date when using the command-line tool tscriptify or the library.

Somewhere in commit a7a821d this code was removed. (see here)

This means that when using the command-line tool tscriptify or the library with default settings, time.Time is no longer converted to Javascript Date objects.


The README says:

This is how now time.Time is managed in the library by default.

Which is not the case, since that automatic conversion code has been removed.

tkrajina commented 3 years ago

Ah, yes, I see. You're right. I changed the README now, thanks!