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

typelevel-ts

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typelevel-ts - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

7

CHANGELOG.md

@@ -16,2 +16,9 @@ # Changelog

# 0.3.3
- **New Feature**
- add `RequiredKeys` and `OptionalKeys` types, #33 (@saitonakamura)
- **Bug Fix**
- KeysOfType now handles optional keys, fix #34 (@gcanti)
# 0.3.2

@@ -18,0 +25,0 @@

18

lib/index.d.ts

@@ -15,3 +15,3 @@ /**

export declare type KeysOfType<A extends object, B> = {
[K in keyof A]: A[K] extends B ? K : never;
[K in keyof A]-?: A[K] extends B ? K : never;
}[keyof A];

@@ -37,1 +37,17 @@ /**

export declare type TaggedUnionMember<A extends object, Tag extends keyof A, Value extends A[Tag]> = Extract<A, Record<Tag, Value>>;
/**
* Extracts required keys as a literal type union
*/
export declare type RequiredKeys<T> = {
[K in keyof T]: {} extends Pick<T, K> ? never : K;
} extends {
[_ in keyof T]: infer U;
} ? U : never;
/**
* Extracts optional keys as a literal type union
*/
export declare type OptionalKeys<T> = {
[K in keyof T]: {} extends Pick<T, K> ? K : never;
} extends {
[_ in keyof T]: infer U;
} ? U : never;

2

package.json
{
"name": "typelevel-ts",
"version": "0.3.2",
"version": "0.3.3",
"description": "Type level programming in TypeScript",

@@ -5,0 +5,0 @@ "files": [

@@ -106,1 +106,11 @@ # TypeScript compatibility

```
## RequiredKeys<A extends object> and OptionalKeys<A extends object>
Extracts required or optional keys as a literal type union
```ts
type A = { a: string; b: number; x?: string; y?: number }
RequiredKeys<A> // "a" | "b"
OptionalKeys<A> // "x" | "y"
```
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