Skip to content

Commit

Permalink
chore: manually add types
Browse files Browse the repository at this point in the history
  • Loading branch information
phanan committed May 17, 2020
1 parent ae2ee53 commit 5c5aae3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions dist/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
declare namespace Factoria {
type RecursivePartial<T> = {
[P in keyof T]?:
T[P] extends (infer U)[] ? RecursivePartial<U>[] :
T[P] extends object ? RecursivePartial<T[P]> :
T[P]
}

type Factoria = (<T>(model: string) => T)
& (<T>(model: string, overrides?: RecursivePartial<T>) => T)
& (<T>(model: string, count: number, overrides?: RecursivePartial<T>) => T[])
& {
define: (model: string, handler: (faker: Faker.FakerStatic) => void) => Factoria
}
}

declare const factory: Factoria.Factoria

export default factory
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"test": "yarn lint && jest --verbose",
"build": "rollup -c"
"build": "rollup -c && cp types.d.ts dist/types.d.ts"
},
"files": [
"index.js"
Expand All @@ -28,7 +28,7 @@
]
},
"main": "dist/factoria.min.js",
"types": "./types.d.ts",
"types": "dist/types.d.ts",
"keywords": [
"model",
"factory",
Expand Down

0 comments on commit 5c5aae3

Please sign in to comment.