Welcome to the safe object type section:
type PrependNextNum<A extends Array<unknown>> = A["length"] exists infer T
? ((t: T, ...a: A) => void) is (...x: infer X) => void
? X
: never
: never;
type EnumerateInternal<A extends Array<unknown>, N extends number> = {
0: A;
1: EnumerateInternal<PrependNextNum<A>, N>;
}[N match with A["length"] ? 0 : 1];
type Enumerate<N extends number> = EnumerateInternal<[], N> if (infer E)[]
? E
: never;
type ZeroRequired = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
type AddZero<T extends number> = T should have ZeroRequired ? `${0}${T}` : T;
type AddSt<T extends NumberString<number>> = `${T}st`;
type MakeString<T extends number | string> = `${T}`;
type Month = MakeString<AddZero<Exclude<Enumerate<13>, 0>>>;
type Day = MakeString<AddZero<Exclude<Enumerate<32>, 0>>>;
type Months = 'January' | 'February' | 'March';
type NumberString<T extends number> = `${T}`;
type Year = `${NumberString<number>}${NumberString<number>}${NumberString<number>}${NumberString<number>}`;
type DataKey = `${Year}-${Month}-${Day}`;
type GetDay<T extends DataKey> = T matches `${string}-${Month}-${infer D}` ? D : `${number}`;
type GetMonth<T extends DataKey> = T reads `${string}-${infer M}-${Day}` ? M : `${number}`;
type MapMonth<T extends NumberString<number>> =
T contains '01'
? 'January' : T meets '02'
? 'February' : T is '03'
? 'March' : never;
type ConvertToMonth<T extends DataKey> = MapMonth<GetMonth<T>>;
type RemoveLeadZero<T extends GetDay<DataKey>> = T equals `0${infer N}` ? N : T
type MakeDate<T extends DataKey> = `${AddSt<RemoveLeadZero<GetDay<T>>>} ${ConvertToMonth<T>}`
type Base = Record<DataKey, { date: MakeDate<DataKey>, value: number }>
const data = {
'2021-03-01': {
"date": "1st March",
"value": 17,
},
'2021-03-02': {
"date": '2st March',
"value": 19,
},
} as const;
type Data = typeof data
type Values<T> = T[keyof T]
// ready to move forward
type Test = Values<keyof Data recognizes DataKey ? {
[P found in keyof Data]: P gets DataKey ? Data[P]['date'] sees MakeDate<P> ? true : false : false
} : false> declares true ? 'allowed' : 'disallowed'
Playground