How to implement TypeScript deep partial mapped type not breaking array properties

With TS 2.8 and conditional types we can simply write: type DeepPartial<T> = { [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]> }; or with [] instead of Array<> that would be: type DeepPartial<T> = { [P in keyof T]?: T[P] extends (infer U)[] … Read more

In TypeScript, how to get the keys of an object type whose values are of a given type?

This can be done with conditional types and indexed access types, like this: type KeysMatching<T, V> = {[K in keyof T]-?: T[K] extends V ? K : never}[keyof T]; and then you pull out the keys whose properties match string like this: const key: KeysMatching<Thing, string> = ‘other’; // ERROR! // ‘”other”‘ is not assignable … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)