Skip to content

Parsing dates doesn't work #54

Closed
Closed
@mattjohnsonpint

Description

@mattjohnsonpint

According to #35 - we should have support for Date types implemented. But this doesn't work:

import { JSON } from "json-as/assembly";

@json
class Foo {
  timestamp!: Date;
}

const foo = JSON.parse<Foo>("{\"timestamp\":\"1999-12-31T23:59:59.999Z\"}");

When compiling, I get:

ERROR TS2322: Type '~lib/date/Date' is not assignable to type '~lib/wasi_date/wasi_Date'.
     :
 294 │ return Date.fromString(data);
     │        ~~~~~~~~~~~~~~~~~~~~~
     └─ in ~lib/json-as/assembly/src/json.ts(294,12)

FAILURE 1 compile error(s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions