Skip to content

Commit

Permalink
feat: add ts typedefs (#32)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Gozala and achingbrain authored Feb 2, 2021
1 parent 7f2a9b9 commit b8fcda8
Show file tree
Hide file tree
Showing 7 changed files with 489 additions and 977 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
pull_request:
branches:
- '*'

name: Typecheck
jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Restore dependencies
id: cache-modules
uses: actions/checkout@v2
with:
path: node_modules
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
- name: Install dependencies
run: npm install
- name: Typecheck
uses: gozala/[email protected]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
npm-debug.*
*.tsbuildinfo
16 changes: 16 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
interface Err<Code> extends Error {
code: Code
}

interface CreateError {
<Code extends string|number, Ext extends Object> (
error:Error,
code: Code,
ext: Ext
): Err<Code> & Ext
<Code extends string|number> (error:Error, code:Code): Err<Code>
<Ext extends Object> (error:Error, ext:Ext): Err<undefined> & Ext
}

declare var createError:CreateError
export = createError
Loading

0 comments on commit b8fcda8

Please sign in to comment.