Extend interface defined in .d.ts file

// How to extend Validator interface adding isArray() method?? You cannot do this in a file that is a module (some guidance here) and your file is a module because you have import expressValidator. Instead create a extendedValidator.d.ts and add the new stuff for TypeScript’s engine: declare module ExpressValidator { export interface Validator { isArray: … Read more

Is there a way to “extract” the type of TypeScript interface property?

It wasn’t possible before but luckily it is now, since TypeScript version 2.1. It has been released on the 7th of December 2016 and it introduces indexed access types also called lookup types. The syntax looks exactly like element access but written in place of types. So in your case: interface I1 { x: any; … Read more