@@ -24,7 +24,7 @@ export namespace common {
2424 * @param file Proto file name
2525 * @returns Root definition or `null` if not defined
2626 */
27- function get ( file : string ) : INamespace ;
27+ function get ( file : string ) : ( INamespace | null ) ;
2828
2929 /** Properties of a google.protobuf.Any message. */
3030 interface IAny {
@@ -186,12 +186,12 @@ export class Enum extends ReflectionObject {
186186 * Adds a value to this enum.
187187 * @param name Value name
188188 * @param id Value id
189- * @param comment Comment, if any
189+ * @param [ comment] Comment, if any
190190 * @returns `this`
191191 * @throws {TypeError } If arguments are invalid
192192 * @throws {Error } If there is already a value with this name or id
193193 */
194- public add ( name : string , id : number , comment : string ) : Enum ;
194+ public add ( name : string , id : number , comment ? : string ) : Enum ;
195195
196196 /**
197197 * Removes a value from this enum
@@ -298,10 +298,10 @@ export class FieldBase extends ReflectionObject {
298298 public map : boolean ;
299299
300300 /** Message this field belongs to. */
301- public message : Type ;
301+ public message : ( Type | null ) ;
302302
303303 /** OneOf this field belongs to, if any, */
304- public partOf : OneOf ;
304+ public partOf : ( OneOf | null ) ;
305305
306306 /** The field type's default value. */
307307 public typeDefault : any ;
@@ -316,13 +316,13 @@ export class FieldBase extends ReflectionObject {
316316 public bytes : boolean ;
317317
318318 /** Resolved type if not a basic type. */
319- public resolvedType : ( Type | Enum ) ;
319+ public resolvedType : ( Type | Enum | null ) ;
320320
321321 /** Sister-field within the extended type if a declaring extension field. */
322- public extensionField : Field ;
322+ public extensionField : ( Field | null ) ;
323323
324324 /** Sister-field within the declaring namespace if an extended field. */
325- public declaringField : Field ;
325+ public declaringField : ( Field | null ) ;
326326
327327 /**
328328 * Converts this field to a field descriptor.
@@ -373,7 +373,7 @@ type FieldDecorator = (prototype: object, fieldName: string) => void;
373373 * @param error Error, if any, otherwise `null`
374374 * @param [root] Root, if there hasn't been an error
375375 */
376- type LoadCallback = ( error : Error , root ?: Root ) => void ;
376+ type LoadCallback = ( error : ( Error | null ) , root ?: Root ) => void ;
377377
378378/**
379379 * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
@@ -434,7 +434,7 @@ export class MapField extends FieldBase {
434434 public keyType : string ;
435435
436436 /** Resolved key type if not a basic type. */
437- public resolvedKeyType : ReflectionObject ;
437+ public resolvedKeyType : ( ReflectionObject | null ) ;
438438
439439 /**
440440 * Constructs a map field from a map field descriptor.
@@ -532,7 +532,7 @@ export class Message<T extends object> {
532532 * @param message Plain object to verify
533533 * @returns `null` if valid, otherwise the reason why it is not
534534 */
535- public static verify ( message : { [ k : string ] : any } ) : string ;
535+ public static verify ( message : { [ k : string ] : any } ) : ( string | null ) ;
536536
537537 /**
538538 * Creates a new message of this type from a plain object. Also converts values to their respective internal types.
@@ -587,10 +587,10 @@ export class Method extends ReflectionObject {
587587 public responseStream ?: boolean ;
588588
589589 /** Resolved request type. */
590- public resolvedRequestType : Type ;
590+ public resolvedRequestType : ( Type | null ) ;
591591
592592 /** Resolved response type. */
593- public resolvedResponseType : Type ;
593+ public resolvedResponseType : ( Type | null ) ;
594594
595595 /**
596596 * Constructs a method from a method descriptor.
@@ -684,7 +684,7 @@ export abstract class NamespaceBase extends ReflectionObject {
684684 * @param name Nested object name
685685 * @returns The reflection object or `null` if it doesn't exist
686686 */
687- public get ( name : string ) : ReflectionObject ;
687+ public get ( name : string ) : ( ReflectionObject | null ) ;
688688
689689 /**
690690 * Gets the values of the nested {@link Enum|enum} of the specified name.
@@ -734,15 +734,15 @@ export abstract class NamespaceBase extends ReflectionObject {
734734 * @param [parentAlreadyChecked=false] If known, whether the parent has already been checked
735735 * @returns Looked up object or `null` if none could be found
736736 */
737- public lookup ( path : ( string | string [ ] ) , filterTypes : ( any | any [ ] ) , parentAlreadyChecked ?: boolean ) : ReflectionObject ;
737+ public lookup ( path : ( string | string [ ] ) , filterTypes : ( any | any [ ] ) , parentAlreadyChecked ?: boolean ) : ( ReflectionObject | null ) ;
738738
739739 /**
740740 * Looks up the reflection object at the specified path, relative to this namespace.
741741 * @param path Path to look up
742742 * @param [parentAlreadyChecked=false] Whether the parent has already been checked
743743 * @returns Looked up object or `null` if none could be found
744744 */
745- public lookup ( path : ( string | string [ ] ) , parentAlreadyChecked ?: boolean ) : ReflectionObject ;
745+ public lookup ( path : ( string | string [ ] ) , parentAlreadyChecked ?: boolean ) : ( ReflectionObject | null ) ;
746746
747747 /**
748748 * Looks up the {@link Type|type} at the specified path, relative to this namespace.
@@ -807,16 +807,16 @@ export abstract class ReflectionObject {
807807 public name : string ;
808808
809809 /** Parent namespace. */
810- public parent : Namespace ;
810+ public parent : ( Namespace | null ) ;
811811
812812 /** Whether already resolved or not. */
813813 public resolved : boolean ;
814814
815815 /** Comment text, if any. */
816- public comment : string ;
816+ public comment : ( string | null ) ;
817817
818818 /** Defining file name. */
819- public filename : string ;
819+ public filename : ( string | null ) ;
820820
821821 /** Reference to the root namespace. */
822822 public readonly root : Root ;
@@ -1173,7 +1173,7 @@ export class Root extends NamespaceBase {
11731173 * @param target The file name being imported
11741174 * @returns Resolved path to `target` or `null` to skip the file
11751175 */
1176- public resolvePath ( origin : string , target : string ) : string ;
1176+ public resolvePath ( origin : string , target : string ) : ( string | null ) ;
11771177
11781178 /**
11791179 * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.
@@ -1218,7 +1218,7 @@ export namespace rpc {
12181218 * @param error Error, if any
12191219 * @param [response] Response message
12201220 */
1221- type ServiceMethodCallback < TRes extends Message < TRes > > = ( error : Error , response ?: TRes ) => void ;
1221+ type ServiceMethodCallback < TRes extends Message < TRes > > = ( error : ( Error | null ) , response ?: TRes ) => void ;
12221222
12231223 /**
12241224 * A service method part of a {@link rpc.Service} as created by {@link Service.create}.
@@ -1240,7 +1240,7 @@ export namespace rpc {
12401240 constructor ( rpcImpl : RPCImpl , requestDelimited ?: boolean , responseDelimited ?: boolean ) ;
12411241
12421242 /** RPC implementation. Becomes `null` once the service is ended. */
1243- public rpcImpl : RPCImpl ;
1243+ public rpcImpl : ( RPCImpl | null ) ;
12441244
12451245 /** Whether requests are length-delimited. */
12461246 public requestDelimited : boolean ;
@@ -1280,7 +1280,7 @@ type RPCImpl = (method: (Method|rpc.ServiceMethod<Message<{}>, Message<{}>>), re
12801280 * @param error Error, if any, otherwise `null`
12811281 * @param [response] Response data or `null` to signal end of stream, if there hasn't been an error
12821282 */
1283- type RPCImplCallback = ( error : Error , response ?: Uint8Array ) => void ;
1283+ type RPCImplCallback = ( error : ( Error | null ) , response ?: ( Uint8Array | null ) ) => void ;
12841284
12851285/** Reflected service. */
12861286export class Service extends NamespaceBase {
@@ -1335,13 +1335,13 @@ export interface IService extends INamespace {
13351335 * Gets the next token and advances.
13361336 * @returns Next token or `null` on eof
13371337 */
1338- type TokenizerHandleNext = ( ) => string ;
1338+ type TokenizerHandleNext = ( ) => ( string | null ) ;
13391339
13401340/**
13411341 * Peeks for the next token.
13421342 * @returns Next token or `null` on eof
13431343 */
1344- type TokenizerHandlePeek = ( ) => string ;
1344+ type TokenizerHandlePeek = ( ) => ( string | null ) ;
13451345
13461346/**
13471347 * Pushes a token back to the stack.
@@ -1363,7 +1363,7 @@ type TokenizerHandleSkip = (expected: string, optional?: boolean) => boolean;
13631363 * @param [line] Line number
13641364 * @returns Comment text or `null` if none
13651365 */
1366- type TokenizerHandleCmnt = ( line ?: number ) => string ;
1366+ type TokenizerHandleCmnt = ( line ?: number ) => ( string | null ) ;
13671367
13681368/** Handle object returned from {@link tokenize}. */
13691369export interface ITokenizerHandle {
@@ -1547,7 +1547,7 @@ export class Type extends NamespaceBase {
15471547 * @param message Plain object to verify
15481548 * @returns `null` if valid, otherwise the reason why it is not
15491549 */
1550- public verify ( message : { [ k : string ] : any } ) : string ;
1550+ public verify ( message : { [ k : string ] : any } ) : ( null | string ) ;
15511551
15521552 /**
15531553 * Creates a new message of this type from a plain object. Also converts values to their respective internal types.
@@ -2381,7 +2381,7 @@ export class Writer {
23812381 public tail : object ;
23822382
23832383 /** Linked forked states. */
2384- public states : object ;
2384+ public states : ( object | null ) ;
23852385
23862386 /**
23872387 * Creates a new writer.
0 commit comments