Skip to content

Commit e1dd1bc

Browse files
committed
Other: With stubs in place, 'number|Long' return values can be just 'Long' instead, see #718
1 parent 404ba8e commit e1dd1bc

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

cli/targets/static.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ function buildFunction(type, functionName, gen, scope) {
250250
push("};");
251251
}
252252

253-
function toJsType(field) {
253+
function toJsType(field, isReturn) {
254254
switch (field.type) {
255255
case "double":
256256
case "float":
@@ -265,7 +265,7 @@ function toJsType(field) {
265265
case "sint64":
266266
case "fixed64":
267267
case "sfixed64":
268-
return "number|Long";
268+
return isReturn ? "Long" : "number|Long";
269269
case "bool":
270270
return "boolean";
271271
case "string":

index.d.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1211,25 +1211,25 @@ export class Reader {
12111211
* Reads a varint as a signed 64 bit value.
12121212
* @name Reader#int64
12131213
* @function
1214-
* @returns {Long|number} Value read
1214+
* @returns {Long} Value read
12151215
*/
1216-
public int64(): (Long|number);
1216+
public int64(): Long;
12171217

12181218
/**
12191219
* Reads a varint as an unsigned 64 bit value.
12201220
* @name Reader#uint64
12211221
* @function
1222-
* @returns {Long|number} Value read
1222+
* @returns {Long} Value read
12231223
*/
1224-
public uint64(): (Long|number);
1224+
public uint64(): Long;
12251225

12261226
/**
12271227
* Reads a zig-zag encoded varint as a signed 64 bit value.
12281228
* @name Reader#sint64
12291229
* @function
1230-
* @returns {Long|number} Value read
1230+
* @returns {Long} Value read
12311231
*/
1232-
public sint64(): (Long|number);
1232+
public sint64(): Long;
12331233

12341234
/**
12351235
* Reads a varint as a boolean.
@@ -1253,17 +1253,17 @@ export class Reader {
12531253
* Reads fixed 64 bits.
12541254
* @name Reader#fixed64
12551255
* @function
1256-
* @returns {Long|number} Value read
1256+
* @returns {Long} Value read
12571257
*/
1258-
public fixed64(): (Long|number);
1258+
public fixed64(): Long;
12591259

12601260
/**
12611261
* Reads zig-zag encoded fixed 64 bits.
12621262
* @name Reader#sfixed64
12631263
* @function
1264-
* @returns {Long|number} Value read
1264+
* @returns {Long} Value read
12651265
*/
1266-
public sfixed64(): (Long|number);
1266+
public sfixed64(): Long;
12671267

12681268
/**
12691269
* Reads a float (32 bit) as a number.

src/reader.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,21 @@ function readLongVarint() {
175175
* Reads a varint as a signed 64 bit value.
176176
* @name Reader#int64
177177
* @function
178-
* @returns {Long|number} Value read
178+
* @returns {Long} Value read
179179
*/
180180

181181
/**
182182
* Reads a varint as an unsigned 64 bit value.
183183
* @name Reader#uint64
184184
* @function
185-
* @returns {Long|number} Value read
185+
* @returns {Long} Value read
186186
*/
187187

188188
/**
189189
* Reads a zig-zag encoded varint as a signed 64 bit value.
190190
* @name Reader#sint64
191191
* @function
192-
* @returns {Long|number} Value read
192+
* @returns {Long} Value read
193193
*/
194194

195195
/**
@@ -250,14 +250,14 @@ function readFixed64(/* this: Reader */) {
250250
* Reads fixed 64 bits.
251251
* @name Reader#fixed64
252252
* @function
253-
* @returns {Long|number} Value read
253+
* @returns {Long} Value read
254254
*/
255255

256256
/**
257257
* Reads zig-zag encoded fixed 64 bits.
258258
* @name Reader#sfixed64
259259
* @function
260-
* @returns {Long|number} Value read
260+
* @returns {Long} Value read
261261
*/
262262

263263
var readFloat = typeof Float32Array !== "undefined"

0 commit comments

Comments
 (0)