concerto
concerto copied to clipboard
TypeScript generation and validation issue for types with dates
I've got more TypeScript fun!
The following model:
concept ExampleEventOutputMetadata {
o DateTime timestamp
}
... generates the following TypeScript:
export interface IExampleEventOutputMetadata extends IConcept {
timestamp: Date;
}
... so I set the timestamp field to new Date()
.
However, Concerto.validate()
rejects such an object with a validation error. It seems to be expecting a string value for timestamp
, as when I override the TypeScript code to set the timestamp
field to an ISO date string, it works fine.
Hey, @sstone1 I would like to work on this issue since I'm new to opensource i don't know from where to start. Can you please assign this to me as I have to get started
Thanks in advance : )
@sstone1 @DianaLease @dselman Please anybody can give me a more detail of this Issues, am interested to solve this issue
I created a new repository to reproduce this issue for anyone that wants to investigate. https://github.com/mttrbrts/concerto-331
There's an open question about whether this is intended behaviour or not.
On the one hand, you could the Concerto API was designed to deal with JavaScript objects that were deserialised from Concerto instances.
However, this use case is a very natural thing to do, and the result is surprising to the user.
The main question is "Should the TypeScript code generation produce Date
types or String
types for Concerto DateTime
fields.