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

Bug/tuple description #1983

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function create<C extends Maybe<AnyObject> = AnyObject, T = any>(
}

interface ArraySchemaSpec<TIn, TContext> extends SchemaSpec<any> {
types?: ISchema<InnerType<TIn>, TContext>
types?: [ISchema<InnerType<TIn>, TContext>]
}

export default class ArraySchema<
Expand All @@ -54,7 +54,7 @@ export default class ArraySchema<
constructor(type?: ISchema<InnerType<TIn>, TContext>) {
super({
type: 'array',
spec: { types: type } as ArraySchemaSpec<TIn, TContext>,
spec: { types: type ? [type] : type } as ArraySchemaSpec<TIn, TContext>,
check(v: any): v is NonNullable<TIn> {
return Array.isArray(v);
},
Expand Down Expand Up @@ -191,7 +191,7 @@ export default class ArraySchema<

next.spec = {
...next.spec,
types: schema as ISchema<InnerType<TIn>, TContext>
types: [schema] as [ISchema<InnerType<TIn>, TContext>]
}

return next as any;
Expand Down