Skip to content

Commit b414d35

Browse files
committed
chore: add test
1 parent d03d834 commit b414d35

13 files changed

+3164
-200
lines changed

.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends":["@curev"]
3+
}

.github/workflows/ci.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
ci:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@4
16+
- run: corepack enable
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
cache: "pnpm"
21+
- run: pnpm install
22+
- run: pnpm lint
23+
- run: pnpm build
24+
- run: pnpm test

.github/workflows/release.yml

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- "v*"
4+
push:
5+
tags:
6+
- 'v*'
77

88
jobs:
9-
release:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v3
13-
with:
14-
fetch-depth: 0
15-
- name: Set node
16-
uses: actions/setup-node@v3
17-
with:
18-
node-version: 16.x
19-
registry-url: "https://registry.npmjs.org"
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
- name: Set node
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 16.x
19+
registry-url: 'https://registry.npmjs.org'
2020

21-
- name: Set up pnpm
22-
uses: pnpm/[email protected]
23-
with:
24-
version: 7.5.2
21+
- name: Set up pnpm
22+
uses: pnpm/[email protected]
23+
with:
24+
version: 7.5.2
2525

26-
- run: npx changelogithub
27-
continue-on-error: true
28-
env:
29-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
26+
- run: npx changelogithub
27+
continue-on-error: true
28+
env:
29+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
3030

31-
- name: Install Dependencies
32-
run: pnpm install
31+
- name: Install Dependencies
32+
run: pnpm install
3333

34-
- name: Publish to NPM
35-
run: pnpm -r publish --access public --no-git-checks
36-
env:
37-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
34+
- name: Publish to NPM
35+
run: pnpm -r publish --access public --no-git-checks
36+
env:
37+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
.env
3-
.pnpm-debug.log
3+
.pnpm-debug.log
4+
*.vitest-temp.json

index.d.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
export type MaybePromise<T = any> = T | Promise<T>
1+
export type MaybePromise<T = any> = Promise<Awaited<T>> | Awaited<T>
22

3-
export type Func<R = void, P extends any[] = any[]> = (...args: P) => R
3+
export type Fn<R = void, P extends any[] = any[]> = (...args: P) => R
44

5-
export type MaybeFunction<T, P extends any[] = any[]> = T | Func<T, P>
5+
export type MaybeFunction<T, P extends any[] = any[]> = T | Fn<T, P>
66

7-
export type MaybeAsyncFunction<T, Promised extends boolean = false, P extends any[] = any[]> = Promised extends true ? MaybeFunction<MaybePromise<T>, P> : Func<MaybePromise<T>, P>
7+
export type MaybeFn<T, P extends any[] = any[]> = MaybeFunction<T,P>
8+
9+
export type MaybeAsyncFunction<T, P extends any[] = any[],Promised extends boolean = T extends Fn ? false : true> = Promised extends true ? MaybeFunction<MaybePromise<T>, P> : Fn<MaybePromise<T>, P>
810

911
export type MaybeArray<T> = T | T[]
1012

@@ -17,3 +19,10 @@ export type MaybeDate = Date | string | number
1719
export type MaybeRegex = RegExp | string
1820

1921
export type MaybeFalsy = false | null | undefined | "" | 0 | void
22+
23+
export type UnwrapPromise <T> = T extends Promise<infer U> ? U : T
24+
25+
export type UnwrapFunction <T> = T extends Fn<infer U> ? U : T
26+
27+
export type UnwrapAsyncFunction <T> = T extends MaybeAsyncFunction<infer U> ? U : T
28+

package.json

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
{
2-
"name": "maybe-types",
3-
"version": "0.0.3",
4-
"description": "",
5-
"types": "index.d.ts",
6-
"scripts": {
7-
"bump": "bumpp --commit --push --tag"
8-
},
9-
"files": [
10-
"index.d.ts"
11-
],
12-
"keywords": [
13-
"types",
14-
"maybe-types"
15-
],
16-
"author": "chizuki",
17-
"license": "MIT",
18-
"devDependencies": {
19-
"bumpp": "^8.2.1"
20-
}
2+
"name": "maybe-types",
3+
"version": "0.0.3",
4+
"description": "",
5+
"author": "chizuki",
6+
"license": "MIT",
7+
"keywords": [
8+
"types",
9+
"maybe-types"
10+
],
11+
"types": "index.d.ts",
12+
"files": [
13+
"index.d.ts"
14+
],
15+
"scripts": {
16+
"bump": "bumpp --commit --push --tag",
17+
"test": "vitest typecheck",
18+
"lint": "eslint ."
19+
},
20+
"devDependencies": {
21+
"@curev/eslint-config": "^0.2.1",
22+
"bumpp": "^8.2.1",
23+
"eslint": "^8.51.0",
24+
"typescript": "^5.2.2",
25+
"vitest": "^1.0.0-beta.1"
26+
}
2127
}

0 commit comments

Comments
 (0)