Skip to content

Commit b8fcda8

Browse files
Gozalaachingbrain
andauthored
feat: add ts typedefs (#32)
* feat: add ts typedefs * fix: address review comments * feat: add type checking to CI * Update index.d.ts Co-authored-by: Alex Potsides <[email protected]> * Update .github/workflows/typecheck.yml Co-authored-by: Alex Potsides <[email protected]>
1 parent 7f2a9b9 commit b8fcda8

File tree

7 files changed

+489
-977
lines changed

7 files changed

+489
-977
lines changed

.github/workflows/typecheck.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- '*'
5+
6+
name: Typecheck
7+
jobs:
8+
check:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: [14.x]
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
- name: Restore dependencies
20+
id: cache-modules
21+
uses: actions/checkout@v2
22+
with:
23+
path: node_modules
24+
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
25+
- name: Install dependencies
26+
run: npm install
27+
- name: Typecheck
28+
uses: gozala/[email protected]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
npm-debug.*
3+
*.tsbuildinfo

index.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
interface Err<Code> extends Error {
2+
code: Code
3+
}
4+
5+
interface CreateError {
6+
<Code extends string|number, Ext extends Object> (
7+
error:Error,
8+
code: Code,
9+
ext: Ext
10+
): Err<Code> & Ext
11+
<Code extends string|number> (error:Error, code:Code): Err<Code>
12+
<Ext extends Object> (error:Error, ext:Ext): Err<undefined> & Ext
13+
}
14+
15+
declare var createError:CreateError
16+
export = createError

0 commit comments

Comments
 (0)