Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Schema type from TypeScript typings #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,8 @@ interface Factory {

declare const factory: Factory

declare namespace factory {
export type Schema = AnySchema
}

export = factory
5 changes: 5 additions & 0 deletions test/typings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import createValidator = require('../')

const foo1: createValidator.Schema = { type: 'number' }
const foo2: createValidator.Schema = { type: 'array', items: { type: 'number' } }
const foo3: createValidator.Schema = { type: 'object', properties: { a: { type: 'number' } } }
const foo4: createValidator.Schema = { oneOf: [{ type: 'number' }, { type: 'string' }] }

/** Static assertion that `value` has type `T` */
// Disable tslint here b/c the generic is used to let us do a type coercion and
// validate that coercion works for the type value "passed into" the function.
Expand Down