Skip to content

Commit 96fa07a

Browse files
committed
Use long.js dependency in tests, reference types instead of paths in .d.ts see #503
1 parent 23d6643 commit 96fa07a

File tree

6 files changed

+41
-70
lines changed

6 files changed

+41
-70
lines changed

.zuul.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ browsers:
1818
version: [8.1, 9.0, latest]
1919
scripts:
2020
- scripts/polyfill.js
21+
- node_modules/long/dist/long.js
2122
tunnel:
2223
type: ngrok
2324
proto: tcp

dist/protobuf.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js.gz

0 Bytes
Binary file not shown.

scripts/types.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ var fs = require("fs"),
44
var dir = path.join(__dirname, "..", "types");
55

66
var header = [
7-
'/// <reference path="../node_modules/@types/node/index.d.ts" />',
8-
'/// <reference path="../node_modules/@types/long/index.d.ts" />',
7+
'/// <reference types="node" />',
8+
'/// <reference types="long" />',
99
"",
1010
"/*",
1111
" * protobuf.js v" + pkg.version + " TypeScript definitions",

types/protobuf.js.d.ts

+36-66
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/// <reference path="../node_modules/@types/node/index.d.ts" />
2-
/// <reference path="../node_modules/@types/long/index.d.ts" />
1+
/// <reference types="node" />
2+
/// <reference types="long" />
33

44
/*
55
* protobuf.js v6.0.1 TypeScript definitions
6-
* Generated Thu, 01 Dec 2016 15:54:46 UTC
6+
* Generated Fri, 02 Dec 2016 12:20:52 UTC
77
*/
88
declare module protobuf {
99

@@ -1619,6 +1619,29 @@ declare module protobuf {
16191619
*/
16201620
var Long: (() => any);
16211621

1622+
/**
1623+
* Converts a number or long to an 8 characters long hash string.
1624+
* @param {Long|number} value Value to convert
1625+
* @returns {string} Hash
1626+
*/
1627+
function longToHash(value: (Long|number)): string;
1628+
1629+
/**
1630+
* Converts an 8 characters long hash string to a long or number.
1631+
* @param {string} hash Hash
1632+
* @param {boolean} [unsigned=false] Whether unsigned or not
1633+
* @returns {Long|number} Original value
1634+
*/
1635+
function longFromHash(hash: string, unsigned?: boolean): (Long|number);
1636+
1637+
/**
1638+
* Tests if two possibly long values are not equal.
1639+
* @param {number|Long} a First value
1640+
* @param {number|Long} b Second value
1641+
* @returns {boolean} `true` if not equal
1642+
*/
1643+
function longNeq(a: (number|Long), b: (number|Long)): boolean;
1644+
16221645
/**
16231646
* Tests if the specified value is a string.
16241647
* @memberof util
@@ -1693,29 +1716,6 @@ declare module protobuf {
16931716
*/
16941717
function resolvePath(originPath: string, importPath: string, alreadyNormalized?: boolean): string;
16951718

1696-
/**
1697-
* Converts a number or long to an 8 characters long hash string.
1698-
* @param {Long|number} value Value to convert
1699-
* @returns {string} Hash
1700-
*/
1701-
function longToHash(value: (Long|number)): string;
1702-
1703-
/**
1704-
* Converts an 8 characters long hash string to a long or number.
1705-
* @param {string} hash Hash
1706-
* @param {boolean} [unsigned=false] Whether unsigned or not
1707-
* @returns {Long|number} Original value
1708-
*/
1709-
function longFromHash(hash: string, unsigned?: boolean): (Long|number);
1710-
1711-
/**
1712-
* Tests if two possibly long values are not equal.
1713-
* @param {number|Long} a First value
1714-
* @param {number|Long} b Second value
1715-
* @returns {boolean} `true` if not equal
1716-
*/
1717-
function longNeq(a: (number|Long), b: (number|Long)): boolean;
1718-
17191719
/**
17201720
* Merges the properties of the source object into the destination object.
17211721
* @param {Object} dst Destination object
@@ -1742,54 +1742,24 @@ declare module protobuf {
17421742
}
17431743

17441744
/**
1745-
* Constructs a new verifier for the specified message type.
1746-
* @classdesc Runtime message verifier using code generation on top of reflection.
1747-
* @constructor
1748-
* @param {Type} type Message type
1745+
* Runtime message verifier using code generation on top of reflection.
1746+
* @namespace
17491747
*/
1750-
class Verifier {
1751-
/**
1752-
* Constructs a new verifier for the specified message type.
1753-
* @classdesc Runtime message verifier using code generation on top of reflection.
1754-
* @constructor
1755-
* @param {Type} type Message type
1756-
*/
1757-
constructor(type: Type);
1758-
1759-
/**
1760-
* Message type.
1761-
* @type {Type}
1762-
*/
1763-
type: Type;
1764-
1765-
/**
1766-
* Fields of this verifier's message type as an array for iteration.
1767-
* @name Verifier#fieldsArray
1768-
* @type {Field[]}
1769-
* @readonly
1770-
*/
1771-
fieldsArray: Field[];
1772-
1773-
/**
1774-
* Full name of this verifier's message type.
1775-
* @name Verifier#fullName
1776-
* @type {string}
1777-
* @readonly
1778-
*/
1779-
fullName: string;
1780-
1748+
module verifier {
17811749
/**
1782-
* Verifies a runtime message of this verifier's message type.
1750+
* Verifies a runtime message of `this` message type.
17831751
* @param {Prototype|Object} message Runtime message or plain object to verify
17841752
* @returns {?string} `null` if valid, otherwise the reason why it is not
1753+
* @this {Type}
17851754
*/
1786-
verify(message: (Prototype|Object)): string;
1755+
function fallback(message: (Prototype|Object)): string;
17871756

17881757
/**
1789-
* Generates a verifier specific to this verifier's message type.
1790-
* @returns {function} Verifier function with an identical signature to {@link Verifier#verify}
1758+
* Generates a verifier specific to the specified message type.
1759+
* @param {Type} mtype Message type
1760+
* @returns {util.CodegenAppender} Unscoped codegen instance
17911761
*/
1792-
generate(): (() => any);
1762+
function generate(mtype: Type): util.CodegenAppender;
17931763

17941764
}
17951765

0 commit comments

Comments
 (0)