Skip to content

Commit bc3cb57

Browse files
authored
Merge pull request #2 from ffMathy/develop
Attempt at perfecting argument inference
2 parents 487d320 + d9b3ec8 commit bc3cb57

24 files changed

+438
-173
lines changed

dist/spec/index.test.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export declare class Example {
22
a: string;
33
c(arg1: string, arg2: string): string;
44
readonly d: number;
5-
v: any;
5+
v: string;
6+
foo(): void;
67
}

dist/spec/index.test.js

Lines changed: 26 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/spec/index.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/Arguments.d.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
export declare class Arg {
2+
static any(): any;
3+
static any<T extends 'string'>(type: T): Argument<string> & string;
4+
static any<T extends 'number'>(type: T): Argument<number> & number;
5+
static any<T extends 'boolean'>(type: T): Argument<boolean> & boolean;
6+
static any<T extends 'array'>(type: T): Argument<any[]> & any[];
7+
static any<T extends 'function'>(type: T): Argument<Function> & Function;
8+
static any<T extends 'string' | 'number' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array'>(type: T): any;
9+
static is<T>(predicate: (input: T) => boolean): Argument<T> & T;
10+
private static toStringify;
11+
}
12+
export declare class Argument<T> {
213
private description;
314
private matchingFunction;
4-
private constructor();
5-
matches(arg: any): boolean;
15+
constructor(description: string, matchingFunction: (arg: T) => boolean);
16+
matches(arg: T): boolean;
617
toString(): string;
718
inspect(): string;
8-
static any(): any;
9-
static any<T extends 'string'>(type: T): Arg & string;
10-
static any<T extends 'number'>(type: T): Arg & number;
11-
static any<T extends 'boolean'>(type: T): Arg & boolean;
12-
static any<T extends 'array'>(type: T): Arg & any[];
13-
static any<T extends 'function'>(type: T): Arg & Function;
14-
static any<T extends 'string' | 'number' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array'>(type: T): any;
15-
static is<T>(predicate: (input: T) => boolean): Arg & T;
16-
private static toStringify;
1719
}

dist/src/Arguments.js

Lines changed: 20 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)