ts-proto 1.115.4 → 1.115.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/build/main.js +9 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.115.5](https://github.com/stephenh/ts-proto/compare/v1.115.4...v1.115.5) (2022-06-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* remove Long import statement when Long was unused ([#599](https://github.com/stephenh/ts-proto/issues/599)) ([58dc10c](https://github.com/stephenh/ts-proto/commit/58dc10c61ec5a76d4b54ba9eddf34021979dd4aa))
|
|
7
|
+
|
|
1
8
|
## [1.115.4](https://github.com/stephenh/ts-proto/compare/v1.115.3...v1.115.4) (2022-06-05)
|
|
2
9
|
|
|
3
10
|
|
package/build/main.js
CHANGED
|
@@ -188,9 +188,6 @@ function generateFile(ctx, fileDesc) {
|
|
|
188
188
|
if (v instanceof ConditionalOutput_1.ConditionalOutput) {
|
|
189
189
|
return ts_poet_1.code `${v.ifUsed}`;
|
|
190
190
|
}
|
|
191
|
-
else if (v instanceof ts_poet_1.Code) {
|
|
192
|
-
return v;
|
|
193
|
-
}
|
|
194
191
|
else {
|
|
195
192
|
return ts_poet_1.code ``;
|
|
196
193
|
}
|
|
@@ -237,23 +234,22 @@ function makeLongUtils(options, bytes) {
|
|
|
237
234
|
//
|
|
238
235
|
// I.e there is not an import for long that "just works" in both esModuleInterop and
|
|
239
236
|
// not esModuleInterop.
|
|
240
|
-
const
|
|
237
|
+
const LongImp = options.esModuleInterop ? ts_poet_1.imp('Long=long') : ts_poet_1.imp('Long*long');
|
|
241
238
|
const disclaimer = options.esModuleInterop
|
|
242
239
|
? ''
|
|
243
240
|
: `
|
|
244
241
|
// If you get a compile-error about 'Constructor<Long> and ... have no overlap',
|
|
245
242
|
// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'.`;
|
|
246
|
-
//
|
|
247
|
-
//
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
: ts_poet_1.code `
|
|
243
|
+
// Instead of exposing `LongImp` directly, let callers think that they are getting the
|
|
244
|
+
// `imp(Long)` but really it is that + our long initialization snippet. This means the
|
|
245
|
+
// initialization code will only be emitted in files that actually use the Long import.
|
|
246
|
+
const Long = ts_poet_1.conditionalOutput('Long', ts_poet_1.code `
|
|
251
247
|
${disclaimer}
|
|
252
|
-
if (${util}.Long !== ${
|
|
253
|
-
${util}.Long = ${
|
|
248
|
+
if (${util}.Long !== ${LongImp}) {
|
|
249
|
+
${util}.Long = ${LongImp} as any;
|
|
254
250
|
${configure}();
|
|
255
251
|
}
|
|
256
|
-
|
|
252
|
+
`);
|
|
257
253
|
// TODO This is unused?
|
|
258
254
|
const numberToLong = ts_poet_1.conditionalOutput('numberToLong', ts_poet_1.code `
|
|
259
255
|
function numberToLong(number: number) {
|
|
@@ -273,7 +269,7 @@ function makeLongUtils(options, bytes) {
|
|
|
273
269
|
return long.toNumber();
|
|
274
270
|
}
|
|
275
271
|
`);
|
|
276
|
-
return { numberToLong, longToNumber, longToString,
|
|
272
|
+
return { numberToLong, longToNumber, longToString, Long };
|
|
277
273
|
}
|
|
278
274
|
function makeByteUtils() {
|
|
279
275
|
const globalThis = ts_poet_1.conditionalOutput('globalThis', ts_poet_1.code `
|