test("cast literal obj having typed tuple [number | null, number | null] as nested prop", () => {
type MinMax = [min: number | null, max: number | null];
class T {
building?: {
area?: MinMax
}
}
// const d = JSON.parse('{"building":{"area":[120,null]}}');
const data: T = cast<T>({
building: {
area: [120, null]
}
});
const errors = validate<T>(data);
expect(errors.length).toBe(0);
});
Error: Could not build function(_context,typeSettings,UnpopulatedCheck,UnpopulatedCheckReturnSymbol,jit_0,isGroupAllowed,jit_1,jit_2,guard_number_0,Number,ValidationError,stringifyValueWithType,guard_number_1,guard_null_0,guard_number_2,guard_null_1,ValidationErrorItem,guard_number_3,guard_number_4,guard_null_2,guard_number_5,guard_null_3): SyntaxError: Identifier 'oldErrors' has already been declared
at CompilerContext.build (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/core/src/compiler.ts:115:19)
at buildFunction (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+type@1.0.1-alpha.151_@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/type/src/serializer.ts:775:34)
at executeTemplates (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+type@1.0.1-alpha.151_@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/type/src/serializer.ts:850:25)
at createConverterJSForMember (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+type@1.0.1-alpha.151_@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/type/src/serializer.ts:874:19)
at serializeObjectLiteral (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+type@1.0.1-alpha.151_@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/type/src/serializer.ts:1234:23)
at executeTemplates (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+type@1.0.1-alpha.151_@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/type/src/serializer.ts:843:13)
at createConverterJSForMember (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+type@1.0.1-alpha.151_@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/type/src/serializer.ts:874:19)
at serializeObjectLiteral (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+type@1.0.1-alpha.151_@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/type/src/serializer.ts:1234:23)
at executeTemplates (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+type@1.0.1-alpha.151_@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/type/src/serializer.ts:843:13)
at createSerializeFunction (file:///C:/PROG/deepform/node_modules/.pnpm/@deepkit+type@1.0.1-alpha.151_@deepkit+core@1.0.1-alpha.147/node_modules/@deepkit/type/src/serializer.ts:241:11)
The following test will throw when executing
cast<T>
More context in discord