ts-proto 1.103.0 → 1.104.0
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 +12 -0
- package/README.markdown +8 -0
- package/build/case.js +3 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [1.104.0](https://github.com/stephenh/ts-proto/compare/v1.103.0...v1.104.0) (2022-01-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Leave mixed case in all words. ([#488](https://github.com/stephenh/ts-proto/issues/488)) ([8a26c9c](https://github.com/stephenh/ts-proto/commit/8a26c9cba4c9897700aafe1a7f59d0b0f537764b))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* enable prototype for defaults for ts-proto-descriptors ([#487](https://github.com/stephenh/ts-proto/issues/487)) ([2b5640f](https://github.com/stephenh/ts-proto/commit/2b5640f582e6adb4e81797a9cec217896061aadb))
|
|
12
|
+
|
|
1
13
|
# [1.103.0](https://github.com/stephenh/ts-proto/compare/v1.102.2...v1.103.0) (2022-01-20)
|
|
2
14
|
|
|
3
15
|
|
package/README.markdown
CHANGED
|
@@ -376,6 +376,14 @@ Generated code will be placed in the Gradle build directory.
|
|
|
376
376
|
|
|
377
377
|
- With `--ts_proto_opt=unknownFields=true`, all unknown fields will be parsed and output as arrays of buffers.
|
|
378
378
|
|
|
379
|
+
- With `--ts_proto_opt=usePrototypeForDefaults=true`, the generated code will wrap new objects with `Object.create`.
|
|
380
|
+
|
|
381
|
+
This allows code to do hazzer checks to detect when default values have been applied, which due to proto3's behavior of not putting default values on the wire, is typically only useful for interacting with proto2 messages.
|
|
382
|
+
|
|
383
|
+
When enabled, default values are inherited from a prototype, and so code can use Object.keys().includes("someField") to detect if someField was actually decoded or not.
|
|
384
|
+
|
|
385
|
+
Note that, as indicated, this means Object.keys will not include set-by-default fields, so if you have code that iterates over messages keys in a generic fashion, it will have to also iterate over keys inherited from the prototype.
|
|
386
|
+
|
|
379
387
|
### Only Types
|
|
380
388
|
|
|
381
389
|
If you're looking for `ts-proto` to generate only types for your Protobuf types then passing all three of `outputEncodeMethods`, `outputJsonMethods`, and `outputClientImpl` as `false` is probably what you want, i.e.:
|
package/build/case.js
CHANGED
|
@@ -7,13 +7,9 @@ function maybeSnakeToCamel(s, options) {
|
|
|
7
7
|
return s
|
|
8
8
|
.split('_')
|
|
9
9
|
.map((word, i) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
return capitalize(word.toLowerCase());
|
|
16
|
-
}
|
|
10
|
+
// If the word is already mixed case, leave the exist case as-is
|
|
11
|
+
word = hasLowerCase ? word : word.toLowerCase();
|
|
12
|
+
return i === 0 ? word : capitalize(word);
|
|
17
13
|
})
|
|
18
14
|
.join('');
|
|
19
15
|
}
|