From e1dd1bc2667de73bb65d876162131be2a4d9fef4 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Fri, 24 Mar 2017 00:02:04 +0100 Subject: [PATCH] Other: With stubs in place, 'number|Long' return values can be just 'Long' instead, see #718 --- cli/targets/static.js | 4 ++-- index.d.ts | 20 ++++++++++---------- src/reader.js | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cli/targets/static.js b/cli/targets/static.js index da97143c7..b90927963 100644 --- a/cli/targets/static.js +++ b/cli/targets/static.js @@ -250,7 +250,7 @@ function buildFunction(type, functionName, gen, scope) { push("};"); } -function toJsType(field) { +function toJsType(field, isReturn) { switch (field.type) { case "double": case "float": @@ -265,7 +265,7 @@ function toJsType(field) { case "sint64": case "fixed64": case "sfixed64": - return "number|Long"; + return isReturn ? "Long" : "number|Long"; case "bool": return "boolean"; case "string": diff --git a/index.d.ts b/index.d.ts index f65cd6471..d1e5f4893 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1211,25 +1211,25 @@ export class Reader { * Reads a varint as a signed 64 bit value. * @name Reader#int64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ - public int64(): (Long|number); + public int64(): Long; /** * Reads a varint as an unsigned 64 bit value. * @name Reader#uint64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ - public uint64(): (Long|number); + public uint64(): Long; /** * Reads a zig-zag encoded varint as a signed 64 bit value. * @name Reader#sint64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ - public sint64(): (Long|number); + public sint64(): Long; /** * Reads a varint as a boolean. @@ -1253,17 +1253,17 @@ export class Reader { * Reads fixed 64 bits. * @name Reader#fixed64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ - public fixed64(): (Long|number); + public fixed64(): Long; /** * Reads zig-zag encoded fixed 64 bits. * @name Reader#sfixed64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ - public sfixed64(): (Long|number); + public sfixed64(): Long; /** * Reads a float (32 bit) as a number. diff --git a/src/reader.js b/src/reader.js index d0a6a0024..4a7e642c7 100644 --- a/src/reader.js +++ b/src/reader.js @@ -175,21 +175,21 @@ function readLongVarint() { * Reads a varint as a signed 64 bit value. * @name Reader#int64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ /** * Reads a varint as an unsigned 64 bit value. * @name Reader#uint64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ /** * Reads a zig-zag encoded varint as a signed 64 bit value. * @name Reader#sint64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ /** @@ -250,14 +250,14 @@ function readFixed64(/* this: Reader */) { * Reads fixed 64 bits. * @name Reader#fixed64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ /** * Reads zig-zag encoded fixed 64 bits. * @name Reader#sfixed64 * @function - * @returns {Long|number} Value read + * @returns {Long} Value read */ var readFloat = typeof Float32Array !== "undefined"