Skip to content

Commit

Permalink
fix(addMethod): allow Schema without making TypeScript upset
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Dec 14, 2023
1 parent a58f02d commit f921fe6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function addMethod<T extends ISchema<any>>(
name: string,
fn: (this: T, ...args: any[]) => T,
): void;
function addMethod<T extends new (...args: any) => ISchema<any>>(
function addMethod<T extends abstract new (...args: any) => ISchema<any>>(
schemaType: T,
name: string,
fn: (this: InstanceType<T>, ...args: any[]) => InstanceType<T>,
Expand Down
5 changes: 5 additions & 0 deletions test/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
bool,
reach,
addMethod,
Schema,
} from '../../src';
import { create as tuple } from '../../src/tuple';
import { create as lazy } from '../../src/Lazy';
Expand Down Expand Up @@ -1079,6 +1080,10 @@ reach: {
}

addMethod: {
addMethod(Schema, 'foo', function () {
return this.clone();
});

addMethod(string, 'foo', function () {
return this.clone();
});
Expand Down

0 comments on commit f921fe6

Please sign in to comment.