diff --git a/README.md b/README.md index a29054dc3..cf760b2f0 100644 --- a/README.md +++ b/README.md @@ -452,6 +452,13 @@ var buffer = AwesomeMessage.encode(message).finish(); ... ``` +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: + +```ts +/// +/// +``` + Documentation ------------- diff --git a/stub-long.d.ts b/stub-long.d.ts index 7099aaa8a..0b8bec495 100644 --- a/stub-long.d.ts +++ b/stub-long.d.ts @@ -1,9 +1,10 @@ -// minimal stub for Long instances for reference when not using long.js. +// minimal stub for Long instances for reference when not using long.js, +// i.e. type Long = LongStub; interface LongStub { lo: number, hi: number, - unsigned: boolean + unsigned?: boolean } diff --git a/stub-node.d.ts b/stub-node.d.ts index 8e0e231d5..f3b3726f2 100644 --- a/stub-node.d.ts +++ b/stub-node.d.ts @@ -1,4 +1,5 @@ -// minimal stub for node types for reference when not using node. +// minimal stub for node types for reference when not using node, +// i.e. type Buffer = BufferStub; diff --git a/tests/data/convert.js b/tests/data/convert.js index 1abd47158..4c3a44069 100644 --- a/tests/data/convert.js +++ b/tests/data/convert.js @@ -17,13 +17,13 @@ $root.Message = (function() { * @type Object * @property {string} [stringVal] Message stringVal. * @property {Array.} [stringRepeated] Message stringRepeated. - * @property {number|$protobuf.Long} [uint64Val] Message uint64Val. - * @property {Array.} [uint64Repeated] Message uint64Repeated. + * @property {number|Long} [uint64Val] Message uint64Val. + * @property {Array.} [uint64Repeated] Message uint64Repeated. * @property {Uint8Array} [bytesVal] Message bytesVal. * @property {Array.} [bytesRepeated] Message bytesRepeated. * @property {number} [enumVal] Message enumVal. * @property {Array.} [enumRepeated] Message enumRepeated. - * @property {Object.} [int64Map] Message int64Map. + * @property {Object.} [int64Map] Message int64Map. */ /** diff --git a/tests/data/mapbox/vector_tile.js b/tests/data/mapbox/vector_tile.js index f9f390bed..d217c3719 100644 --- a/tests/data/mapbox/vector_tile.js +++ b/tests/data/mapbox/vector_tile.js @@ -234,9 +234,9 @@ $root.vector_tile = (function() { * @property {string} [stringValue] Value stringValue. * @property {number} [floatValue] Value floatValue. * @property {number} [doubleValue] Value doubleValue. - * @property {number|$protobuf.Long} [intValue] Value intValue. - * @property {number|$protobuf.Long} [uintValue] Value uintValue. - * @property {number|$protobuf.Long} [sintValue] Value sintValue. + * @property {number|Long} [intValue] Value intValue. + * @property {number|Long} [uintValue] Value uintValue. + * @property {number|Long} [sintValue] Value sintValue. * @property {boolean} [boolValue] Value boolValue. */ @@ -534,7 +534,7 @@ $root.vector_tile = (function() { * Properties of a Feature. * @typedef vector_tile.Tile.Feature$Properties * @type Object - * @property {number|$protobuf.Long} [id] Feature id. + * @property {number|Long} [id] Feature id. * @property {Array.} [tags] Feature tags. * @property {*} [type] Feature type. * @property {Array.} [geometry] Feature geometry. diff --git a/tests/data/test.d.ts b/tests/data/test.d.ts index b2f387997..19f34bc81 100644 --- a/tests/data/test.d.ts +++ b/tests/data/test.d.ts @@ -303,7 +303,7 @@ export namespace jspb { type DefaultValues$Properties = { stringField?: string; boolField?: boolean; - intField?: (number|$protobuf.Long); + intField?: (number|Long); enumField?: number; emptyField?: string; bytesField?: Uint8Array; @@ -597,7 +597,7 @@ export namespace jspb { type TestMapFieldsNoBinary$Properties = { mapStringString?: { [k: string]: string }; mapStringInt32?: { [k: string]: number }; - mapStringInt64?: { [k: string]: (number|$protobuf.Long) }; + mapStringInt64?: { [k: string]: (number|Long) }; mapStringBool?: { [k: string]: boolean }; mapStringDouble?: { [k: string]: number }; mapStringEnum?: { [k: string]: number }; @@ -1218,8 +1218,8 @@ export namespace google { type UninterpretedOption$Properties = { name?: google.protobuf.UninterpretedOption.NamePart[]; identifierValue?: string; - positiveIntValue?: (number|$protobuf.Long); - negativeIntValue?: (number|$protobuf.Long); + positiveIntValue?: (number|Long); + negativeIntValue?: (number|Long); doubleValue?: number; stringValue?: Uint8Array; aggregateValue?: string; diff --git a/tests/data/test.js b/tests/data/test.js index efe2700a6..4539253ef 100644 --- a/tests/data/test.js +++ b/tests/data/test.js @@ -2891,7 +2891,7 @@ $root.jspb = (function() { * @type Object * @property {string} [stringField] DefaultValues stringField. * @property {boolean} [boolField] DefaultValues boolField. - * @property {number|$protobuf.Long} [intField] DefaultValues intField. + * @property {number|Long} [intField] DefaultValues intField. * @property {number} [enumField] DefaultValues enumField. * @property {string} [emptyField] DefaultValues emptyField. * @property {Uint8Array} [bytesField] DefaultValues bytesField. @@ -5905,7 +5905,7 @@ $root.jspb = (function() { * @type Object * @property {Object.} [mapStringString] TestMapFieldsNoBinary mapStringString. * @property {Object.} [mapStringInt32] TestMapFieldsNoBinary mapStringInt32. - * @property {Object.} [mapStringInt64] TestMapFieldsNoBinary mapStringInt64. + * @property {Object.} [mapStringInt64] TestMapFieldsNoBinary mapStringInt64. * @property {Object.} [mapStringBool] TestMapFieldsNoBinary mapStringBool. * @property {Object.} [mapStringDouble] TestMapFieldsNoBinary mapStringDouble. * @property {Object.} [mapStringEnum] TestMapFieldsNoBinary mapStringEnum. @@ -12463,8 +12463,8 @@ $root.google = (function() { * @type Object * @property {Array.} [name] UninterpretedOption name. * @property {string} [identifierValue] UninterpretedOption identifierValue. - * @property {number|$protobuf.Long} [positiveIntValue] UninterpretedOption positiveIntValue. - * @property {number|$protobuf.Long} [negativeIntValue] UninterpretedOption negativeIntValue. + * @property {number|Long} [positiveIntValue] UninterpretedOption positiveIntValue. + * @property {number|Long} [negativeIntValue] UninterpretedOption negativeIntValue. * @property {number} [doubleValue] UninterpretedOption doubleValue. * @property {Uint8Array} [stringValue] UninterpretedOption stringValue. * @property {string} [aggregateValue] UninterpretedOption aggregateValue.