Skip to content

Commit

Permalink
chore: add typings (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
climba03003 authored May 22, 2021
1 parent 77c81e2 commit 176ddf8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
13 changes: 13 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Ajv, Options } from "ajv";

export type ValidatorCompiler = (
externalSchemas: unknown,
options: Options,
cache: Options["cache"]
) => Ajv;

export declare function ValidatorSelector(): ValidatorCompiler;

export type { Ajv, Options } from "ajv";

export default ValidatorSelector;
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
"version": "1.0.0",
"description": "Build and manage the AJV instances for the fastify framework",
"main": "index.js",
"types": "index.d.ts",
"directories": {
"test": "test"
},
"scripts": {
"lint:fix": "standard --fix",
"test": "standard && tap --100 test/**/*.test.js"
"unit": "tap --100 test/**/*.test.js",
"test": "standard && npm run unit && npm run test:typescript",
"test:typescript": "tsd"
},
"repository": {
"type": "git",
Expand All @@ -31,9 +34,13 @@
"ajv-errors": "^1.0.1",
"ajv-merge-patch": "^4.1.0",
"standard": "^16.0.3",
"tap": "^15.0.1"
"tap": "^15.0.1",
"tsd": "^0.14.0"
},
"dependencies": {
"ajv": "^6.12.6"
},
"tsd": {
"directory": "test/types"
}
}
6 changes: 6 additions & 0 deletions test/types/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { expectType } from "tsd";
import ValidatorSelector, { ValidatorCompiler } from "../..";

const compiler = ValidatorSelector();

expectType<ValidatorCompiler>(compiler);

0 comments on commit 176ddf8

Please sign in to comment.