smart-result 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src/index.ts → lib/index.d.ts} +4 -4
- package/lib/index.js +2 -0
- package/package.json +5 -1
- package/CHANGELOG.md +0 -2
- package/tsconfig.json +0 -14
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type OkResult<Data extends true | Record<string, any>> = {
|
|
7
7
|
readonly error?: never;
|
|
8
|
-
// If the result is `{}`, set it to `Record<string, unknown>` to make type resolution work as expected when the result branches.
|
|
9
8
|
readonly ok: [keyof Data] extends [never] ? Record<string, unknown> : Data;
|
|
10
9
|
};
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* Type of the result in case of error.
|
|
14
12
|
*/
|
|
15
|
-
export type ErrorResult<Error extends Record<string, any>> = {
|
|
16
|
-
|
|
13
|
+
export type ErrorResult<Error extends Record<string, any>> = {
|
|
14
|
+
readonly error: Error;
|
|
15
|
+
readonly ok?: never;
|
|
16
|
+
};
|
|
17
17
|
/**
|
|
18
18
|
* Object type for easier handling of results.
|
|
19
19
|
*
|
package/lib/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smart-result",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "yarn clean && tsc -p ./tsconfig.json",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"homepage": "https://github.com/misuken-now/smart-result#readme",
|
|
23
23
|
"main": "./lib/index.js",
|
|
24
24
|
"typings": "./lib/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"lib",
|
|
27
|
+
"!**/__tests__"
|
|
28
|
+
],
|
|
25
29
|
"devDependencies": {
|
|
26
30
|
"generate-changelog": "^1.8.0",
|
|
27
31
|
"del-cli": "^4.0.1",
|
package/CHANGELOG.md
DELETED
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"outDir": "./lib",
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"forceConsistentCasingInFileNames": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"skipLibCheck": true
|
|
11
|
-
},
|
|
12
|
-
"include": ["src/**/*.ts"],
|
|
13
|
-
"exclude": ["node_modules"]
|
|
14
|
-
}
|