Issue with Type Inference in Schema Transformation
export const CreateDialingPermissionsSchema = Schema.Struct({
...ClientSchema.fields,
updateRequest: Schema.transform(
Schema.String,
Schema.Array(DialingPermissionEntrySchema),
{
decode: (input) => JSON.parse(input),
encode: (input) => JSON.stringify(input),
},
),
});
export type CreateDialingPermissions =
typeof CreateDialingPermissionsSchema.Type;export const CreateDialingPermissionsSchema = Schema.Struct({
...ClientSchema.fields,
updateRequest: Schema.transform(
Schema.String,
Schema.Array(DialingPermissionEntrySchema),
{
decode: (input) => JSON.parse(input),
encode: (input) => JSON.stringify(input),
},
),
});
export type CreateDialingPermissions =
typeof CreateDialingPermissionsSchema.Type;I have a problem when create a type from schema, it infers the type as:
updateRequest: Schema.transform<typeof Schema.String, Schema.Array$<Schema.Struct<{
iso_code: typeof Schema.String;
low_risk_numbers_enabled: typeof Schema.Boolean;
high_risk_special_numbers_enabled: typeof Schema.Boolean;
high_risk_tollfraud_numbers_enabled: typeof Schema.Boolean;
}>>>;
accountSid: typeof Schema.NonEmptyString;
authToken: typeof Schema.NonEmptyString;updateRequest: Schema.transform<typeof Schema.String, Schema.Array$<Schema.Struct<{
iso_code: typeof Schema.String;
low_risk_numbers_enabled: typeof Schema.Boolean;
high_risk_special_numbers_enabled: typeof Schema.Boolean;
high_risk_tollfraud_numbers_enabled: typeof Schema.Boolean;
}>>>;
accountSid: typeof Schema.NonEmptyString;
authToken: typeof Schema.NonEmptyString;But this is wrong, the from type should be a string
