-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Labels
type/bugSomething isn't workingSomething isn't workingversion/4.xIssues related to the 4.0 release of this libraryIssues related to the 4.0 release of this library
Description
It appears that time
constructor attribute value, which can be Date
is always converted to a string:
sdk-javascript/src/event/cloudevent.ts
Lines 91 to 95 in 73f0bec
if (!this.#_time) { | |
this.#_time = new Date().toISOString(); | |
} else if (this.#_time instanceof Date) { | |
this.#_time = this.#_time.toISOString(); | |
} |
The setter also converts to a string:
sdk-javascript/src/event/cloudevent.ts
Lines 130 to 132 in 73f0bec
set time(val: string | Date) { | |
this.#_time = new Date(val).toISOString(); | |
} |
Yet, the value of the getter is type casted to string | Date
. This is actually confusing and leads to buggy behavior.
This led me to a wrong conclusion, that if I pass a Date
it will remain a Date
.
sdk-javascript/src/event/cloudevent.ts
Line 126 in 73f0bec
get time(): string | Date { |
Metadata
Metadata
Assignees
Labels
type/bugSomething isn't workingSomething isn't workingversion/4.xIssues related to the 4.0 release of this libraryIssues related to the 4.0 release of this library