Skip to content

Null semantics regression in 7.5.0 #2074

@Tofandel

Description

@Tofandel

The feature introduced in #2011 has been broken by #2051

Reproduction

Clone https://github.com/Tofandel/protobuf-regression
Run npm install && npm run test
This will install protobuffjs 7.4.0 and run the build script
Then will install protobuffjs 7.5.2 and run the build script again, and finally run a diff of the 2 ts builds

Output of the command

> test
> npm i [email protected] && npm run build && mv protos.js protos.old.js && mv protos.d.ts protos.old.d.ts && npm i protobufjs@^7.5.0 && npm run build && diff -u protos.old.d.ts protos.d.ts


changed 1 package, and audited 82 packages in 996ms

> build
> npm run build:js && npm run build:ts


> build:js
> pbjs --force-message --null-semantics -t static-module --force-number --dependency protobufjs/minimal.js --es6 -o ./protos.js *.proto && sed -i -e 's/\$util.Long/false/' -e 's/options.longs === String/false/' protos.js


> build:ts
> pbts -o protos.d.ts ./protos.js && sed -i -e 's/import Long = require("long");//' protos.d.ts


changed 1 package, and audited 82 packages in 891ms

> build
> npm run build:js && npm run build:ts


> build:js
> pbjs --force-message --null-semantics -t static-module --force-number --dependency protobufjs/minimal.js --es6 -o ./protos.js *.proto && sed -i -e 's/\$util.Long/false/' -e 's/options.longs === String/false/' protos.js


> build:ts
> pbts -o protos.d.ts ./protos.js && sed -i -e 's/import Long = require("long");//' protos.d.ts

--- protos.old.d.ts     2025-05-23 14:58:13.184164934 +0200
+++ protos.d.ts 2025-05-23 14:58:13.729137394 +0200
@@ -7,10 +7,10 @@
     interface IAddress {

         /** Address type */
-        type?: (string|undefined);
+        type?: (string|null|undefined);

         /** Address address_1 */
-        address_1?: (string|undefined);
+        address_1?: (string|null|undefined);

         /** Address address_2 */
         address_2?: (string|null|undefined);
@@ -26,14 +26,17 @@
         constructor(properties?: Protos.IAddress);

         /** Address type. */
-        public type: string;
+        public type: (string|null);

         /** Address address_1. */
-        public address_1: string;
+        public address_1: (string|null);

         /** Address address_2. */
         public address_2: (string|null);

+        /** Address _address_2. */
+        public _address_2?: "address_2";
+
         /**
          * Creates a new Address instance using the specified properties.
          * @param [properties] Properties to set

All fields are now nullable which was not the case before

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions