-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for "type": "date-time"
#183
Comments
That's a great suggestion @ellis! Since these go in the /**
* This represents a string in RFC3339 date format.
* Eg. `2018 09 18`
*/
type DateString = string
/**
* This represents a string in RFC3339 date format.
* Eg. `24 59 58`
*/
type TimeString = string
// After
interface MyInterface {
startDate: DateString
endTime: TimeString
}
// Before
interface MyInterface {
startDate: string
endTime: string
} Contributions are welcome. If you'd like to take this on:
|
For now nominal types can be expressed via type DateString = string & {__tag: 'DateString'}; Can we implement it like this? |
most people will use use a parser/reviver that supports actual compile(user, 'User', {
formatTypes: {
'date': 'Date',
'date-time': 'Date',
},
}); I managed to get the above using the import {map} from 'ramda';
const prepareSchema = (schema: any) =>
typeof schema === 'object'
? schema.format === 'date' || schema.format === 'date-time'
? { ...schema, tsType: 'Date' }
: map(prepareSchema, schema)
: schema;
compile(prepareSchema(user), 'User'); |
Is there a support plan now? |
3 years since the issue has been created. Can you please share whether this is not on a roadmap or can we expect it at some point in the future? Thank you for your work |
Guys is it available yet? I have to change format to date from date-time manually every time I run this script :( |
We can use the tsType property in our JSON schema to override the type. tsType Overrides the type that's generated from the schema. Helpful in forcing a type to any or when using non-standard JSON schema extensions. For Example, the JSON schema given below generates a type birthday with date as it's type.
|
I prefer approaches like #183 (comment). Feel free to correct me if I'm misunderstanding. |
Could you please add support for the types
date-time
,date
, andtime
?The text was updated successfully, but these errors were encountered: