@@ -7,6 +7,7 @@ import {matcherConfig} from "./urlMatcherConfig";
7
7
import { Param } from "../params/param" ;
8
8
import { paramTypes } from "../params/paramTypes" ;
9
9
import { ParamType } from "../params/type" ;
10
+ import { ParamTypeDefinition } from "../params/interface" ;
10
11
11
12
/** @hidden */
12
13
function getDefaultConfig ( ) {
@@ -92,21 +93,25 @@ export class UrlMatcherFactory {
92
93
} ;
93
94
94
95
/**
95
- * Creates and registers a custom [[ParamType]] object that can be used to generate URLs with typed parameters.
96
+ * Creates and registers a custom [[ParamType]] object
97
+ *
98
+ * A [[ParamType]] can be used to generate URLs with typed parameters.
96
99
*
97
100
* @param name The type name.
98
101
* @param definition The type definition. See [[ParamTypeDefinition]] for information on the values accepted.
99
- * @param definitionFn A function that is injected before the app
100
- * runtime starts. The result of this function is merged into the existing `definition`.
102
+ * @param definitionFn A function that is injected before the app runtime starts.
103
+ * The result of this function should be a [[ParamTypeDefinition]].
104
+ * The result is merged into the existing `definition`.
101
105
* See [[ParamType]] for information on the values accepted.
102
106
*
103
107
* @returns - if a type was registered: the [[UrlMatcherFactory]]
104
108
* - if only the `name` parameter was specified: the currently registered [[ParamType]] object, or undefined
105
109
*
106
- * This is a simple example of a custom type that encodes and decodes items from an
107
- * array, using the array index as the URL-encoded value:
110
+ * Note: Register custom types *before using them* in a state definition.
111
+ *
112
+ * See [[ParamTypeDefinition]] for examples
108
113
*/
109
- type ( name : string , definition ?: ( Function | ParamType ) , definitionFn ?: Function ) {
114
+ type ( name : string , definition ?: ParamTypeDefinition , definitionFn ?: ( ) => ParamTypeDefinition ) {
110
115
let type = paramTypes . type ( name , definition , definitionFn ) ;
111
116
return ! isDefined ( definition ) ? type : this ;
112
117
} ;
0 commit comments