type OriginalType = { key1: { sub1: string; sub2: string }; key2: { subA: string; subB: string }; }; type ValidKeys = keyof OriginalType; type ValidSubKeys = keyof OriginalType[K]; type FixedLengthArray = [T, ...T[]] & { length: L }; type EnforcedRecord = { [K in ValidKeys]: FixedLengthArray, L>; }; // Example usage: const example: EnforcedRecord<2> = { key1: ['sub1', 'sub2'], // Valid key2: ['subA', 'subB'], // Valid // key1: ['sub1'], // Invalid, TypeScript will give an error // key2: ['subA', 'subB', 'subC'], // Invalid, TypeScript will give an error };