Skip to content

Commit 3c2694b

Browse files
committed
Added AllOrNoneType.
1 parent 200356c commit 3c2694b

17 files changed

+119
-39
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.10.0
1+
20.0.0

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 20.0.0

ROADMAP.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

class/all-or-none.type.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @description Requires all of the given keys or none of the given keys in the given interface.
3+
* @summary ```import type { AllOrNoneType } from '@corefunc/type/class/all-or-none.type';```
4+
* @since 1.5.0
5+
*/
6+
export declare type AllOrNoneType<Interface, Keys extends keyof Interface> = (Required<Pick<Interface, Keys>> | Partial<Record<Keys, never>>) & Omit<Interface, Keys>;

class/all-or-none.type.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @description Requires all of the given keys or none of the given keys in the given interface.
3+
* @summary ```import type { AllOrNoneType } from '@corefunc/type/class/all-or-none.type';```
4+
* @since 1.5.0
5+
*/
6+
export type AllOrNoneType<Interface, Keys extends keyof Interface> = (
7+
| Required<Pick<Interface, Keys>>
8+
| Partial<Record<Keys, never>>
9+
) &
10+
Omit<Interface, Keys>;

class/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from "./all-or-none.type";
12
export * from "./complete.type";
23
export * from "./concrete.type";
34
export * from "./constructor.type";

class/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
1414
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1515
};
1616
exports.__esModule = true;
17+
__exportStar(require("./all-or-none.type"), exports);
1718
__exportStar(require("./complete.type"), exports);
1819
__exportStar(require("./concrete.type"), exports);
1920
__exportStar(require("./constructor.type"), exports);

class/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from "./all-or-none.type";
12
export * from "./complete.type";
23
export * from "./concrete.type";
34
export * from "./constructor.type";

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
- Class
2+
- [All Or None](/class/all-or-none.md)
23
- [Complete](/class/complete.type.md)
34
- [Concrete](/class/concrete.type.md)
45
- [Constructor](/class/constructor.type.md)

docs/class/all-or-none.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Class
2+
3+
## All or None
4+
5+
> Requires all of the given keys or none of the given keys in the given interface.
6+
7+
_Since `1.5.0`_
8+
9+
```typescript
10+
import { type AllOrNoneType } from "@corefunc/type/class/all-or-none.type";
11+
12+
interface User {
13+
name: string;
14+
age?: number;
15+
email?: number;
16+
}
17+
18+
const user_1: AllOrNoneType<User, "age" | "email"> = {
19+
name: "John",
20+
};
21+
22+
const user_2: AllOrNoneType<User, "age" | "email"> = {
23+
name: "John",
24+
age: 33,
25+
email: "john@doe.email",
26+
};
27+
```

0 commit comments

Comments
 (0)