Useful Typescript / Angular code snippets

Below are some useful code snippets I wrote. I use them as a reference, because they when I occasionally need them, I never know them by heart. Hope this will help you too. If so, let me know in the comments. Convert enum to array export function enumToArray<T>(enumObj: object): T[] {   const enumKeys: string[] = Object.keys(enumObj);   const enumValues = enumKeys.map((key) => key as any).map((v) => enumObj[v] as any);   return enumValues as T[]; } Set all controls in Angular […]

VisualStudio has problem when multiple versions of Typescript are installed

You can have several versions of Typescript installed on your machine and each project in Visual Studio can be configured to use different version by specifying that version in .csproj file. Like this But you might still have problems with IntelliSense for some native javascript objects. VisualStudio uses file lib.d.ts  to learn interfaces of window objects, events, […]