You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I'm trying merge two schemas but I'd like to change the property keys in the intersected type.
// First schemaconstDataFromJson=Type.Object({key: Type.String(),});// Second schemaconstDataFromEnv=Type.Object({SETTING: Type.String(),});// magicconstintersectedSchema=Type.Object({SETTING: Type.String(),OVERRIDE_key: Type.String(),});
Why do I want to do this? I'd like to add overrides for values in a json file with a given schema to my environment variables. I'm trying to avoid to redeclare the overrides. I'm currently trying to get a deeper understanding of Typescript and learn more and I stumbled accross this issue here, and I manage to rename the property with this code, but the resulting value is always any:
typeTFromDescriptor<TextendsTSchema,KextendsPropertyKey,>=KextendskeyofT
? TB.Evaluate<Record<`OVERRIDE_${TB.Assert<K,string>}`,T[K]>>
: {};constfoo=FromDescriptor(DataFromJson,'key');// will result in:constfoo: {OVERRIDE_key: any;}
Maybe somebody has a hint? Or maybe this is just a bad idea overall :)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey, I'm trying merge two schemas but I'd like to change the property keys in the intersected type.
Why do I want to do this? I'd like to add overrides for values in a json file with a given schema to my environment variables. I'm trying to avoid to redeclare the overrides. I'm currently trying to get a deeper understanding of Typescript and learn more and I stumbled accross this issue here, and I manage to rename the property with this code, but the resulting value is always
any
:Maybe somebody has a hint? Or maybe this is just a bad idea overall :)
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions