concerto icon indicating copy to clipboard operation
concerto copied to clipboard

TypeScript generation and validation issue for types with dates

Open sstone1 opened this issue 3 years ago • 4 comments

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.

sstone1 avatar Sep 02 '21 18:09 sstone1

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 : )

Krish-bhardwaj avatar Jan 18 '22 05:01 Krish-bhardwaj

@sstone1 @DianaLease @dselman Please anybody can give me a more detail of this Issues, am interested to solve this issue

alsoarpit avatar Feb 05 '22 04:02 alsoarpit

I created a new repository to reproduce this issue for anyone that wants to investigate. https://github.com/mttrbrts/concerto-331

mttrbrts avatar May 31 '22 14:05 mttrbrts

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.

mttrbrts avatar May 31 '22 14:05 mttrbrts