Handle dates

This commit is contained in:
Convly 2022-07-21 08:46:35 +02:00
parent 870dd61c28
commit d0168cf957

View File

@ -11,6 +11,7 @@ const {
isNull,
isString,
isNumber,
isDate,
isArray,
isBoolean,
propEq,
@ -101,6 +102,10 @@ const toTypeLiteral = data => {
return factory.createTupleTypeNode(data.map(item => toTypeLiteral(item)));
}
if (isDate(data)) {
return factory.createTypeReferenceNode('Date');
}
if (typeof data !== 'object') {
throw new Error(`Cannot convert to object literal. Unknown type "${typeof data}"`);
}