Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

ts-essentials

Package Overview
Dependencies
Maintainers
3
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-essentials

All essential TypeScript types in one place

  • 10.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8M
decreased by-9.51%
Maintainers
3
Weekly downloads
ย 
Created

What is ts-essentials?

The ts-essentials package provides a set of TypeScript types to enhance the TypeScript typing experience, offering more strict and powerful type definitions. It includes utility types, type guards, and other helpers that are not available in the standard TypeScript library.

What are ts-essentials's main functionalities?

DeepReadonly

Makes all properties of an object type recursively readonly. It is useful for defining immutable state or configurations.

type MyObject = { a: { b: { c: number } } };\nconst readonlyObject: DeepReadonly<MyObject> = { a: { b: { c: 1 } } };\n// readonlyObject.a.b.c = 2; // Error: Cannot assign to 'c' because it is a read-only property.

Writable

Converts a readonly object into a writable one, removing the readonly modifier from all properties.

type MyReadOnlyObject = { readonly a: number };\nconst writable: Writable<MyReadOnlyObject> = { a: 1 };\nwritable.a = 2; // No error, 'a' is writable.

StrictOmit

Creates a type by omitting the keys provided from the given object type, ensuring that only keys that exist on the type are specified.

interface MyObject { a: number; b: string; c: boolean; }\nconst myObject: StrictOmit<MyObject, 'a' | 'b'> = { c: true };\n// myObject.a or myObject.b does not exist.

LiteralUnion

Allows for a union type to include specific literal types as well as additional types, typically used for string literals with an escape hatch for other values.

type Direction = LiteralUnion<'left' | 'right', string>;\nconst direction: Direction = 'any string'; // No error, can be 'left', 'right', or any other string.

MarkRequired

Marks certain properties of an object type as required, changing them from optional to mandatory.

type MyObject = { a?: number; b: string; }\nconst required: MarkRequired<MyObject, 'a'> = { a: 1, b: 'string' };\n// Property 'a' is required in 'required'.

Other packages similar to ts-essentials

Keywords

FAQs

Package last updated on 01 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc