Skip to content

Commit 3ba3ad7

Browse files
committed
Docs: Added information on how to use the stubs to README, see #718
1 parent 0bc4a14 commit 3ba3ad7

File tree

7 files changed

+27
-18
lines changed

7 files changed

+27
-18
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,13 @@ var buffer = AwesomeMessage.encode(message).finish();
452452
...
453453
```
454454

455+
If you'd like to completely exclude long.js and/or node (Buffer) typings, there are two stubs available that can be referenced instead of the full type definitions:
456+
457+
```ts
458+
/// <reference path="node_modules/protobufjs/stub-long.d.ts" />
459+
/// <reference path="node_modules/protobufjs/stub-node.d.ts" />
460+
```
461+
455462
Documentation
456463
-------------
457464

stub-long.d.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// minimal stub for Long instances for reference when not using long.js.
1+
// minimal stub for Long instances for reference when not using long.js,
2+
// i.e. <reference path="node_modules/protobufjs/stub-long.d.ts" />
23

34
type Long = LongStub;
45

56
interface LongStub {
67
lo: number,
78
hi: number,
8-
unsigned: boolean
9+
unsigned?: boolean
910
}

stub-node.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// minimal stub for node types for reference when not using node.
1+
// minimal stub for node types for reference when not using node,
2+
// i.e. <reference path="node_modules/protobufjs/stub-node.d.ts" />
23

34
type Buffer = BufferStub;
45

tests/data/convert.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ $root.Message = (function() {
1717
* @type Object
1818
* @property {string} [stringVal] Message stringVal.
1919
* @property {Array.<string>} [stringRepeated] Message stringRepeated.
20-
* @property {number|$protobuf.Long} [uint64Val] Message uint64Val.
21-
* @property {Array.<number|$protobuf.Long>} [uint64Repeated] Message uint64Repeated.
20+
* @property {number|Long} [uint64Val] Message uint64Val.
21+
* @property {Array.<number|Long>} [uint64Repeated] Message uint64Repeated.
2222
* @property {Uint8Array} [bytesVal] Message bytesVal.
2323
* @property {Array.<Uint8Array>} [bytesRepeated] Message bytesRepeated.
2424
* @property {number} [enumVal] Message enumVal.
2525
* @property {Array.<number>} [enumRepeated] Message enumRepeated.
26-
* @property {Object.<string,number|$protobuf.Long>} [int64Map] Message int64Map.
26+
* @property {Object.<string,number|Long>} [int64Map] Message int64Map.
2727
*/
2828

2929
/**

tests/data/mapbox/vector_tile.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ $root.vector_tile = (function() {
234234
* @property {string} [stringValue] Value stringValue.
235235
* @property {number} [floatValue] Value floatValue.
236236
* @property {number} [doubleValue] Value doubleValue.
237-
* @property {number|$protobuf.Long} [intValue] Value intValue.
238-
* @property {number|$protobuf.Long} [uintValue] Value uintValue.
239-
* @property {number|$protobuf.Long} [sintValue] Value sintValue.
237+
* @property {number|Long} [intValue] Value intValue.
238+
* @property {number|Long} [uintValue] Value uintValue.
239+
* @property {number|Long} [sintValue] Value sintValue.
240240
* @property {boolean} [boolValue] Value boolValue.
241241
*/
242242

@@ -534,7 +534,7 @@ $root.vector_tile = (function() {
534534
* Properties of a Feature.
535535
* @typedef vector_tile.Tile.Feature$Properties
536536
* @type Object
537-
* @property {number|$protobuf.Long} [id] Feature id.
537+
* @property {number|Long} [id] Feature id.
538538
* @property {Array.<number>} [tags] Feature tags.
539539
* @property {*} [type] Feature type.
540540
* @property {Array.<number>} [geometry] Feature geometry.

tests/data/test.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export namespace jspb {
303303
type DefaultValues$Properties = {
304304
stringField?: string;
305305
boolField?: boolean;
306-
intField?: (number|$protobuf.Long);
306+
intField?: (number|Long);
307307
enumField?: number;
308308
emptyField?: string;
309309
bytesField?: Uint8Array;
@@ -597,7 +597,7 @@ export namespace jspb {
597597
type TestMapFieldsNoBinary$Properties = {
598598
mapStringString?: { [k: string]: string };
599599
mapStringInt32?: { [k: string]: number };
600-
mapStringInt64?: { [k: string]: (number|$protobuf.Long) };
600+
mapStringInt64?: { [k: string]: (number|Long) };
601601
mapStringBool?: { [k: string]: boolean };
602602
mapStringDouble?: { [k: string]: number };
603603
mapStringEnum?: { [k: string]: number };
@@ -1218,8 +1218,8 @@ export namespace google {
12181218
type UninterpretedOption$Properties = {
12191219
name?: google.protobuf.UninterpretedOption.NamePart[];
12201220
identifierValue?: string;
1221-
positiveIntValue?: (number|$protobuf.Long);
1222-
negativeIntValue?: (number|$protobuf.Long);
1221+
positiveIntValue?: (number|Long);
1222+
negativeIntValue?: (number|Long);
12231223
doubleValue?: number;
12241224
stringValue?: Uint8Array;
12251225
aggregateValue?: string;

tests/data/test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2891,7 +2891,7 @@ $root.jspb = (function() {
28912891
* @type Object
28922892
* @property {string} [stringField] DefaultValues stringField.
28932893
* @property {boolean} [boolField] DefaultValues boolField.
2894-
* @property {number|$protobuf.Long} [intField] DefaultValues intField.
2894+
* @property {number|Long} [intField] DefaultValues intField.
28952895
* @property {number} [enumField] DefaultValues enumField.
28962896
* @property {string} [emptyField] DefaultValues emptyField.
28972897
* @property {Uint8Array} [bytesField] DefaultValues bytesField.
@@ -5905,7 +5905,7 @@ $root.jspb = (function() {
59055905
* @type Object
59065906
* @property {Object.<string,string>} [mapStringString] TestMapFieldsNoBinary mapStringString.
59075907
* @property {Object.<string,number>} [mapStringInt32] TestMapFieldsNoBinary mapStringInt32.
5908-
* @property {Object.<string,number|$protobuf.Long>} [mapStringInt64] TestMapFieldsNoBinary mapStringInt64.
5908+
* @property {Object.<string,number|Long>} [mapStringInt64] TestMapFieldsNoBinary mapStringInt64.
59095909
* @property {Object.<string,boolean>} [mapStringBool] TestMapFieldsNoBinary mapStringBool.
59105910
* @property {Object.<string,number>} [mapStringDouble] TestMapFieldsNoBinary mapStringDouble.
59115911
* @property {Object.<string,number>} [mapStringEnum] TestMapFieldsNoBinary mapStringEnum.
@@ -12463,8 +12463,8 @@ $root.google = (function() {
1246312463
* @type Object
1246412464
* @property {Array.<google.protobuf.UninterpretedOption.NamePart>} [name] UninterpretedOption name.
1246512465
* @property {string} [identifierValue] UninterpretedOption identifierValue.
12466-
* @property {number|$protobuf.Long} [positiveIntValue] UninterpretedOption positiveIntValue.
12467-
* @property {number|$protobuf.Long} [negativeIntValue] UninterpretedOption negativeIntValue.
12466+
* @property {number|Long} [positiveIntValue] UninterpretedOption positiveIntValue.
12467+
* @property {number|Long} [negativeIntValue] UninterpretedOption negativeIntValue.
1246812468
* @property {number} [doubleValue] UninterpretedOption doubleValue.
1246912469
* @property {Uint8Array} [stringValue] UninterpretedOption stringValue.
1247012470
* @property {string} [aggregateValue] UninterpretedOption aggregateValue.

0 commit comments

Comments
 (0)