Skip to content

Commit

Permalink
fix mapToNumVal typings
Browse files Browse the repository at this point in the history
otherwise the returned type is never
  • Loading branch information
Bessonov committed May 14, 2024
1 parent cb6b5f2 commit c5b7a8f
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 71 deletions.
2 changes: 1 addition & 1 deletion dist/examples/node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions dist/matchers/EndpointMatcher.d.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { type Matcher, type MatchResult, type Method, type QueryMatch, type QueryResult, type QueryStringMatcherInput } from './index.js';
import type { RegExpMatch, RegExpResult } from './RegExpPathnameMatcher.js';
import { type Matcher, type MatchResult, type Method, type QueryStringMatch, type QueryStringMatcherInput, type QueryStringResult } from './index.js';
import type { RegExpPathnameMatch, RegExpPathnameResult } from './RegExpPathnameMatcher.js';
export interface EndpointMatcherInput {
req: {
url: string;
method: string;
};
}
export type EndpointMatchResult<R extends RegExpMatch, U extends QueryMatch> = MatchResult<{
export type EndpointMatchResult<R extends RegExpPathnameMatch, U extends QueryStringMatch> = MatchResult<{
method: Method;
pathname: RegExpResult<R>;
query: QueryResult<U>;
pathname: RegExpPathnameResult<R>;
query: QueryStringResult<U>;
}>;
/**
* higher order matcher which is combine matching of method
* with regular expression
*/
export declare class EndpointMatcher<R extends RegExpMatch, P extends EndpointMatcherInput = EndpointMatcherInput, U extends QueryMatch = QueryMatch, QP extends QueryStringMatcherInput = QueryStringMatcherInput> implements Matcher<EndpointMatchResult<R, U>, P> {
export declare class EndpointMatcher<R extends RegExpPathnameMatch, P extends EndpointMatcherInput = EndpointMatcherInput, U extends QueryStringMatch = QueryStringMatch, QP extends QueryStringMatcherInput = QueryStringMatcherInput> implements Matcher<EndpointMatchResult<R, U>, P> {
private readonly matcher;
constructor(methods: Method | Method[], urls: RegExp | string | (RegExp | string)[], params?: {
url?: R;
query?: U;
});
match(params: EndpointMatcherInput): EndpointMatchResult<R, U>;
}
export declare function endpoint<R extends RegExpMatch, P extends EndpointMatcherInput = EndpointMatcherInput, U extends QueryMatch = QueryMatch, QP extends QueryStringMatcherInput = QueryStringMatcherInput>(...args: ConstructorParameters<typeof EndpointMatcher<R, P, U, QP>>): EndpointMatcher<R, P, U, QP>;
export declare function endpoint<R extends RegExpPathnameMatch, P extends EndpointMatcherInput = EndpointMatcherInput, U extends QueryStringMatch = QueryStringMatch, QP extends QueryStringMatcherInput = QueryStringMatcherInput>(...args: ConstructorParameters<typeof EndpointMatcher<R, P, U, QP>>): EndpointMatcher<R, P, U, QP>;
2 changes: 1 addition & 1 deletion dist/matchers/EndpointMatcher.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions dist/matchers/QueryStringMatcher.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import type { AnyValidator, Validator } from '../validators.js';
import type { FirstValidator, ValidatorReturnType } from '../validators.js';
import type { Matcher } from './Matcher.js';
import type { MatchResult } from './MatchResult.js';
export interface QueryStringMatcherInput {
req: {
url: string;
};
}
export type QueryMatch = Record<string, AnyValidator>;
export type QueryResult<T extends QueryMatch> = {
[P in keyof T]: T[P] extends Validator<string[] | null, infer O> ? O : never;
export type QueryStringMatch = Record<string, FirstValidator<string[] | undefined>>;
export type QueryStringResult<T extends QueryStringMatch> = {
[P in keyof T]: ValidatorReturnType<T[P]>;
};
export type QueryStringMatchResult<U extends QueryMatch> = MatchResult<{
query: QueryResult<U>;
export type QueryStringMatchResult<U extends QueryStringMatch> = MatchResult<{
query: QueryStringResult<U>;
}>;
declare class QueryStringMatcher<U extends QueryMatch, P extends QueryStringMatcherInput> implements Matcher<QueryStringMatchResult<U>, P> {
declare class QueryStringMatcher<U extends QueryStringMatch, P extends QueryStringMatcherInput> implements Matcher<QueryStringMatchResult<U>, P> {
private readonly listConfig;
constructor(config: U);
match: ({ req }: P) => QueryStringMatchResult<U>;
}
export declare function queryString<U extends QueryMatch, P extends QueryStringMatcherInput>(config: U): QueryStringMatcher<U, P>;
export declare function queryString<U extends QueryStringMatch, P extends QueryStringMatcherInput>(config: U): QueryStringMatcher<U, P>;
export {};
2 changes: 1 addition & 1 deletion dist/matchers/QueryStringMatcher.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions dist/matchers/RegExpPathnameMatcher.d.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import type { AnyValidator, Validator } from '../index.js';
import type { FirstValidator, ValidatorReturnType } from '../index.js';
import type { Matcher } from './Matcher.js';
import type { MatchResult } from './MatchResult.js';
export interface RegExpPathnameMatcherInput {
req: {
url: string;
};
}
export type RegExpMatch = Record<string, AnyValidator>;
export type RegExpResult<T extends RegExpMatch> = {
export type RegExpPathnameMatch = Record<string, FirstValidator<string[] | undefined>>;
export type RegExpPathnameResult<T extends RegExpPathnameMatch> = {
url: string;
params: {
[P in keyof T]: T[P] extends Validator<string[] | null, infer O> ? O : never;
[P in keyof T]: ValidatorReturnType<T[P]>;
};
};
export type RegExpPathnameMatchResult<R extends RegExpMatch> = MatchResult<{
pathname: RegExpResult<R>;
export type RegExpPathnameMatchResult<R extends RegExpPathnameMatch> = MatchResult<{
pathname: RegExpPathnameResult<R>;
}>;
declare class RegExpPathnameMatcher<R extends RegExpMatch, P extends RegExpPathnameMatcherInput = RegExpPathnameMatcherInput> implements Matcher<RegExpPathnameMatchResult<R>, P> {
declare class RegExpPathnameMatcher<R extends RegExpPathnameMatch, P extends RegExpPathnameMatcherInput = RegExpPathnameMatcherInput> implements Matcher<RegExpPathnameMatchResult<R>, P> {
private readonly urls;
private readonly listConfig;
constructor(urls: RegExp[], config?: R);
match({ req }: RegExpPathnameMatcherInput): RegExpPathnameMatchResult<R>;
}
export declare function regExpPathname<R extends RegExpMatch, P extends RegExpPathnameMatcherInput = RegExpPathnameMatcherInput>(urls: RegExp[], config?: R): RegExpPathnameMatcher<R, P>;
export declare function regExpPathname<R extends RegExpPathnameMatch, P extends RegExpPathnameMatcherInput = RegExpPathnameMatcherInput>(urls: RegExp[], config?: R): RegExpPathnameMatcher<R, P>;
export {};
2 changes: 1 addition & 1 deletion dist/matchers/RegExpPathnameMatcher.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/matchers/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export { type ExtractMatchResult, type Matcher, } from './Matcher.js';
export { isMatched, type Matched, type MatchedResult, type MatchResult, type MatchResultAny, type UnmatchedResult, } from './MatchResult.js';
export { type Method, method, MethodMatcher, type MethodMatcherInput, type MethodMatchResult, } from './MethodMatcher.js';
export { or, OrMatcher, type OrMatcherResult, } from './OrMatcher.js';
export { type QueryMatch, type QueryResult, queryString, type QueryStringMatcherInput, type QueryStringMatchResult, } from './QueryStringMatcher.js';
export { queryString, type QueryStringMatch, type QueryStringMatcherInput, type QueryStringMatchResult, type QueryStringResult, } from './QueryStringMatcher.js';
export { regExpPathname, type RegExpPathnameMatcherInput, type RegExpPathnameMatchResult, } from './RegExpPathnameMatcher.js';
export { RegExpUrlMatcher, type RegExpUrlMatcherInput, type RegExpUrlMatchResult, } from './RegExpUrlMatcher.js';
2 changes: 1 addition & 1 deletion dist/matchers/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c5b7a8f

Please sign in to comment.