Relative Content

Tag Archive for typescripttypescript-types

How to check if type (not object) has a specific property?

I am working with a generated complex type that is rather big. I need to check if certain properties exists on the type with create a variable and initializing all its properties to default/null values, since that would be too much work.

TypeScript sort changes type of array

Setup Let’s say I have the following type: interface MyType { myProperty: [a: string[], b: string[]] } And now I want to create an array out of that type: const array1: MyType[] = [ {myProperty: [[“Hello”, “World”], []]}, {myProperty: [[“Hello”], []]}, ]; The problem If I now try to sort that array, I get an […]