11/**
22 * This is an internal function.
33 */
4- function internalFunction ( ) :void { }
5-
4+ function internalFunction ( ) : void { }
65
76/**
87 * This is a simple exported function.
98 */
10- export function exportedFunction ( ) :void { }
11-
9+ export function exportedFunction ( ) : void { }
1210
1311/**
1412 * This is a function with multiple arguments and a return value.
@@ -27,30 +25,27 @@ export function exportedFunction():void { }
2725 *
2826 * @returns This is the return value of the function.
2927 */
30- export function functionWithParameters ( paramZ :string , paramG :any , paramA :Object ) :number {
28+ export function functionWithParameters ( paramZ : string , paramG : any , paramA : Object ) : number {
3129 return 0 ;
3230}
3331
34-
3532/**
3633 * This is a function that is assigned to a variable.
3734 *
3835 * @param someParam This is some numeric parameter.
3936 * @return This is the return value of the function.
4037 */
41- export const variableFunction = function ( someParam :number ) :number {
38+ export const variableFunction = function ( someParam : number ) : number {
4239 return 0 ;
4340} ;
4441
45-
4642/**
4743 * This is a function with a parameter that is optional.
4844 *
4945 * @param requiredParam A normal parameter.
5046 * @param optionalParam An optional parameter.
5147 */
52- export function functionWithOptionalValue ( requiredParam :string , optionalParam ?:string ) { }
53-
48+ export function functionWithOptionalValue ( requiredParam : string , optionalParam ?: string ) { }
5449
5550/**
5651 * This is a function with a parameter that has a default value.
@@ -63,51 +58,49 @@ export function functionWithOptionalValue(requiredParam:string, optionalParam?:s
6358 * @return This is the return value of the function.
6459 */
6560export function functionWithDefaults (
66- valueA :string = 'defaultValue' ,
67- valueB :number = 100 ,
68- valueC :number = Number . NaN ,
69- valueD :boolean = true ,
70- valueE :boolean = null
71- ) :string {
61+ valueA : string = 'defaultValue' ,
62+ valueB : number = 100 ,
63+ valueC : number = Number . NaN ,
64+ valueD : boolean = true ,
65+ valueE : boolean = null
66+ ) : string {
7267 return valueA ;
7368}
7469
75-
7670/**
7771 * This is a function with rest parameter.
7872 *
7973 * @param rest The rest parameter.
8074 * @return This is the return value of the function.
8175 */
82- function functionWithRest ( ...rest :string [ ] ) :string {
76+ function functionWithRest ( ...rest : string [ ] ) : string {
8377 return rest . join ( ', ' ) ;
8478}
8579
86-
8780/**
8881 * This is the first signature of a function with multiple signatures.
8982 *
9083 * @param value The name value.
9184 */
92- export function multipleSignatures ( value :string ) :string ;
85+ export function multipleSignatures ( value : string ) : string ;
9386
9487/**
9588 * This is the second signature of a function with multiple signatures.
9689 *
9790 * @param value An object containing the name value.
9891 * @param value.name A value of the object.
9992 */
100- export function multipleSignatures ( value :{ name :string } ) :string ;
93+ export function multipleSignatures ( value : { name : string } ) : string ;
10194
10295/**
10396 * This is the actual implementation, this comment will not be visible
10497 * in the generated documentation.
10598 *
10699 * @return This is the return value of the function.
107100 */
108- export function multipleSignatures ( ) :string {
101+ export function multipleSignatures ( ) : string {
109102 if ( arguments . length > 0 ) {
110- if ( typeof arguments [ 0 ] == 'object' ) {
103+ if ( typeof arguments [ 0 ] === 'object' ) {
111104 return arguments [ 0 ] . name ;
112105 } else {
113106 return arguments [ 0 ] ;
@@ -117,33 +110,54 @@ export function multipleSignatures():string {
117110 return '' ;
118111}
119112
120-
121113/**
122114 * This is a function that is extended by a module.
123115 *
124116 * @param arg An argument.
125117 */
126- export function moduleFunction ( arg :string ) :string { return '' ; }
127-
118+ export function moduleFunction ( arg : string ) : string { return '' ; }
128119
129120/**
130121 * This is an assertion function.
131122 *
132123 * @param condition The condition that is asserted to be true when this function returns.
133124 */
134- export function assertionFunction ( condition :boolean ) :asserts condition { }
125+ export function assertionFunction ( condition : boolean ) : asserts condition { }
126+
127+ /**
128+ * Assertion function with a type.
129+ * @param anything
130+ */
131+ export function checkerFunction ( anything : any ) : anything is string {
132+ return typeof anything === 'string' ;
133+ }
135134
135+ /**
136+ * Asserts that an argument is not null.
137+ * @param arg
138+ */
139+ export function assertIsNonNull < T > ( arg : T | null | undefined ) : asserts arg is T {
140+ if ( arg == null ) {
141+ throw new Error ( 'Was nullable' ) ;
142+ }
143+ }
144+
145+ /**
146+ * Checks that an argument is not null.
147+ * @param arg
148+ */
149+ export function isNonNull < T > ( arg : T | null | undefined ) : arg is T {
150+ return arg != null ;
151+ }
136152
137153/**
138154 * This is the module extending the function moduleFunction().
139155 */
140- export module moduleFunction
141- {
156+ export module moduleFunction {
142157 /**
143158 * This variable is appended to a function.
144159 */
145- let functionVariable :string ;
146-
160+ let functionVariable : string ;
147161
148162 /**
149163 * This function is appended to another function.
0 commit comments