@bufbuild/protoc-gen-es 1.7.1 → 1.7.2
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/dist/cjs/package.json +4 -4
- package/dist/cjs/src/declaration.js +2 -1
- package/package.json +4 -4
- package/src/declaration.ts +3 -1
- package/tsconfig.json +2 -2
package/dist/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protoc-gen-es",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Protocol Buffers code generator for ECMAScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"preferUnplugged": true,
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@bufbuild/protobuf": "^1.7.
|
|
24
|
-
"@bufbuild/protoplugin": "1.7.
|
|
23
|
+
"@bufbuild/protobuf": "^1.7.2",
|
|
24
|
+
"@bufbuild/protoplugin": "1.7.2"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@bufbuild/protobuf": "1.7.
|
|
27
|
+
"@bufbuild/protobuf": "1.7.2"
|
|
28
28
|
},
|
|
29
29
|
"peerDependenciesMeta": {
|
|
30
30
|
"@bufbuild/protobuf": {
|
|
@@ -112,8 +112,9 @@ function generateField(schema, f, field) {
|
|
|
112
112
|
f.print(f.jsDoc(field, " "));
|
|
113
113
|
const e = [];
|
|
114
114
|
e.push(" ", (0, ecmascript_1.localName)(field));
|
|
115
|
+
const { defaultValue } = (0, ecmascript_1.getFieldIntrinsicDefaultValue)(field);
|
|
115
116
|
const { typing, optional } = (0, ecmascript_1.getFieldTyping)(field, f);
|
|
116
|
-
if (optional) {
|
|
117
|
+
if (optional || defaultValue === undefined) {
|
|
117
118
|
e.push("?: ", typing);
|
|
118
119
|
}
|
|
119
120
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protoc-gen-es",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Protocol Buffers code generator for ECMAScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"preferUnplugged": true,
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@bufbuild/protobuf": "^1.7.
|
|
24
|
-
"@bufbuild/protoplugin": "1.7.
|
|
23
|
+
"@bufbuild/protobuf": "^1.7.2",
|
|
24
|
+
"@bufbuild/protoplugin": "1.7.2"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@bufbuild/protobuf": "1.7.
|
|
27
|
+
"@bufbuild/protobuf": "1.7.2"
|
|
28
28
|
},
|
|
29
29
|
"peerDependenciesMeta": {
|
|
30
30
|
"@bufbuild/protobuf": {
|
package/src/declaration.ts
CHANGED
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
} from "@bufbuild/protoplugin/ecmascript";
|
|
27
27
|
import {
|
|
28
28
|
getFieldTyping,
|
|
29
|
+
getFieldIntrinsicDefaultValue,
|
|
29
30
|
localName,
|
|
30
31
|
reifyWkt,
|
|
31
32
|
} from "@bufbuild/protoplugin/ecmascript";
|
|
@@ -138,8 +139,9 @@ function generateField(schema: Schema, f: GeneratedFile, field: DescField) {
|
|
|
138
139
|
f.print(f.jsDoc(field, " "));
|
|
139
140
|
const e: Printable = [];
|
|
140
141
|
e.push(" ", localName(field));
|
|
142
|
+
const { defaultValue } = getFieldIntrinsicDefaultValue(field);
|
|
141
143
|
const { typing, optional } = getFieldTyping(field, f);
|
|
142
|
-
if (optional) {
|
|
144
|
+
if (optional || defaultValue === undefined) {
|
|
143
145
|
e.push("?: ", typing);
|
|
144
146
|
} else {
|
|
145
147
|
e.push(": ", typing);
|
package/tsconfig.json
CHANGED