• Typescript Daily
  • Posts
  • Pick your favorite and use it in your Typescript project today!

Pick your favorite and use it in your Typescript project today!

13 real-world use cases to go through to expand your horizon.

🎯 TypeScript Daily Digest!

Today’s edition of Typescript Daily looks at 13 custom real-world type checks/utilities you can make use of right away in your projects.

These utilities range from performing a DeepRequired check on the nested levels and merging multiple object structures, to using conditions as well.

DeepRequired: Make all properties of an object and nested objects required.

Flatten: Flatten a nested object structure into a single level.

FunctionArguments: Extract the argument types from a function type.

EnumValues: Obtain an array of all values from an enum.

GetReturnType: Get the return type of a function, including promises.

OptionalKeys: Extract keys from an object type that corresponds to optional properties.

RequiredKeys: Extract keys from an object type that corresponds to required properties.

Trim: Trim whitespace from all property values of an object.

OptionalExceptFor: Make specific properties required while keeping the rest optional.

ValueOf: Obtain the union type of all property values from an object.

Merge: Combine multiple objects' types into one.

Falsy: Exclude falsy values (e.g., undefined, null, false) from a union type.

NonNullableProperties: Extract a type with all properties of an object that are non-nullable.

These custom TypeScript utility types can help you solve real-world challenges and write more expressive, type-safe code. Feel free to adapt and extend these examples to suit your specific needs.

🏁 Wrapping It Up

Another day, another dive into the world of TypeScript. As we cross the finish line today, remember to keep exploring, keep learning, and most importantly, keep coding. If you found value in today's insights, please consider sharing this newsletter with friends or on social media — every share helps us reach more TypeScript enthusiasts like you! Stay tuned for tomorrow's journey.

Reply

or to participate.