Skip to content

Commit db2dd49

Browse files
committed
Fixed: Prevent invalid JSDoc names when generating service methods, see #870
1 parent 6229799 commit db2dd49

File tree

7 files changed

+521
-3
lines changed

7 files changed

+521
-3
lines changed

cli/targets/static.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ function buildService(ref, service) {
645645
push("");
646646
pushComment([
647647
method.comment || "Calls " + method.name + ".",
648-
"@function " + util.safeProp(lcName),
648+
"@function " + lcName,
649649
"@memberof " + exportName(service),
650650
"@instance",
651651
"@param {" + exportName(method.resolvedRequestType, !config.forceMessage) + "} request " + method.resolvedRequestType.name + " message or plain object",

scripts/gentests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var fs = require("fs"),
1111
{ file: "tests/data/package.proto", flags: [] },
1212
{ file: "tests/data/rpc.proto", flags: [ "es6" ] },
1313
{ file: "tests/data/rpc.proto", flags: [] },
14+
{ file: "tests/data/rpc-reserved.proto", flags: [] },
1415
{ file: "tests/data/test.proto", flags: [] },
1516
{ file: "bench/data/bench.proto", flags: ["no-create", "no-verify", "no-delimited", "no-convert", "no-comments"], out: "bench/data/static_pbjs.js" }
1617
]
@@ -50,6 +51,7 @@ process.stdout.write("\n");
5051
{ file: "tests/data/package.js" },
5152
{ file: "tests/data/rpc.js" },
5253
{ file: "tests/data/rpc-es6.js" },
54+
{ file: "tests/data/rpc-reserved.js" },
5355
{ file: "tests/data/test.js" },
5456
{ file: "ext/descriptor/index.js", ext: true }
5557
]

tests/data/rpc-es6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const MyService = $root.MyService = (() => {
5050

5151
/**
5252
* Calls MyMethod.
53-
* @function .myMethod
53+
* @function myMethod
5454
* @memberof MyService
5555
* @instance
5656
* @param {IMyRequest} request MyRequest message or plain object

tests/data/rpc-reserved.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import * as $protobuf from "../..";
2+
3+
export class MyService extends $protobuf.rpc.Service {
4+
constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean);
5+
public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): MyService;
6+
public delete(request: IMyRequest, callback: MyService.DeleteCallback): void;
7+
public delete(request: IMyRequest): Promise<MyResponse>;
8+
}
9+
10+
export namespace MyService {
11+
12+
type DeleteCallback = (error: (Error|null), response?: MyResponse) => void;
13+
}
14+
15+
export interface IMyRequest {
16+
path?: (string|null);
17+
}
18+
19+
export class MyRequest implements IMyRequest {
20+
constructor(properties?: IMyRequest);
21+
public path: string;
22+
public static create(properties?: IMyRequest): MyRequest;
23+
public static encode(message: IMyRequest, writer?: $protobuf.Writer): $protobuf.Writer;
24+
public static encodeDelimited(message: IMyRequest, writer?: $protobuf.Writer): $protobuf.Writer;
25+
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): MyRequest;
26+
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): MyRequest;
27+
public static verify(message: { [k: string]: any }): (string|null);
28+
public static fromObject(object: { [k: string]: any }): MyRequest;
29+
public static toObject(message: MyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any };
30+
public toJSON(): { [k: string]: any };
31+
}
32+
33+
export interface IMyResponse {
34+
status?: (number|null);
35+
}
36+
37+
export class MyResponse implements IMyResponse {
38+
constructor(properties?: IMyResponse);
39+
public status: number;
40+
public static create(properties?: IMyResponse): MyResponse;
41+
public static encode(message: IMyResponse, writer?: $protobuf.Writer): $protobuf.Writer;
42+
public static encodeDelimited(message: IMyResponse, writer?: $protobuf.Writer): $protobuf.Writer;
43+
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): MyResponse;
44+
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): MyResponse;
45+
public static verify(message: { [k: string]: any }): (string|null);
46+
public static fromObject(object: { [k: string]: any }): MyResponse;
47+
public static toObject(message: MyResponse, options?: $protobuf.IConversionOptions): { [k: string]: any };
48+
public toJSON(): { [k: string]: any };
49+
}

0 commit comments

Comments
 (0)