Skip to content

Commit

Permalink
Remove doc blocks that will need revisiting
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Sep 4, 2021
1 parent 571ca44 commit 73a2bcb
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ export function normalizeParam<P extends ParamOrString> (p: P): NormalizeParam<P
return p as NormalizeParam<P>
}

/**
* Normalizes the type of params specified as strings into Param types
*
* - For string types, the type becomes the name of the param, and the Arg and Result types become "string"
* - All other params are returned as-is
*/
export type NormalizeParam<NameOrParam extends ParamOrString> = NameOrParam extends string
? Param<NameOrParam>
: Cast<NameOrParam, AnyParam>
Expand All @@ -39,14 +33,7 @@ export interface Param<Name extends string, Arg = string> {
format: (arg: Arg) => string
}

/**
* Extracts the arg type from a param type
*/
export type ParamArg<Subject extends AnyParam> = Subject extends Param<string, infer Arg> ? Arg : never

/**
* A Param type, or a string type to be normalized into a Param type via NormalizeParam
*/
export type ParamOrString = AnyParam | string

export interface PathPattern<Params extends AnyParams> {
Expand Down Expand Up @@ -122,21 +109,12 @@ export function path<Params extends ParamsOrStrings> (
type AnyParams = AnyParam[]
type ParamsOrStrings = ParamOrString[]

/**
* Constructs the type for the result of a successful match against a path with the supplied param types
*/
type Result<Params extends AnyParams> = Params extends Array<Param<infer Name, any>>
? { [Key in Name]: ParamArg<Extract<Params[number], Param<Key, any>>> }
: { [Key in string]: any }

/**
* Constructs the type for acceptable input when building a path with the supplied param types
*/
type Args<Params extends AnyParams> = AllowOmitUndefined<Result<Params>> & { [Key in string]: any }

/**
* Normalizes an indexed access type (i.e. an array type) of param types, using NormalizeParam
*/
type NormalizeParams<Params extends ParamsOrStrings> = {
[Key in keyof Params]: NormalizeParam<Cast<Params[Key], ParamOrString>>
}

0 comments on commit 73a2bcb

Please sign in to comment.