Skip to content

Bug: time attribute is always a string, yet is type casted to string | Date #326

@moltar

Description

@moltar

It appears that time constructor attribute value, which can be Date is always converted to a string:

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:

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.

get time(): string | Date {

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't workingversion/4.xIssues related to the 4.0 release of this library

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions