Skip to content

Commit

Permalink
Make sure to add non-default longtype to map field info for #260
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm committed Mar 25, 2022
1 parent 1a22444 commit 58e1b79
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 229 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
### unreleased changes

Bug fixes:

- Make sure to add non-default longtype to map field info, see #260


New Features:

- Add option `eslint_disable`, which generates a comment /* eslint-disable */ at the
Expand Down
8 changes: 5 additions & 3 deletions packages/plugin/src/code-gen/field-info-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,18 @@ export class FieldInfoGenerator {
break;
case "scalar":
T = this.createScalarType(mapV.T);
if (mapV.L)
if (mapV.L !== undefined)
L = this.createLongType(mapV.L);
break;
}
let properties: ts.ObjectLiteralElementLike[] = [
const properties: ts.ObjectLiteralElementLike[] = [
ts.createPropertyAssignment(ts.createIdentifier('kind'), ts.createStringLiteral(mapV.kind)),
ts.createPropertyAssignment(ts.createIdentifier('T'), T)
];
if (L) {
ts.createPropertyAssignment(ts.createIdentifier('L'), L)
properties.push(
ts.createPropertyAssignment(ts.createIdentifier('L'), L)
);
}
return ts.createObjectLiteral(properties);
}
Expand Down
2 changes: 0 additions & 2 deletions packages/test-fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import msgOneofs from './msg-oneofs.fixtures'
import msgScalar from './msg-scalar.fixtures'
import msgEnum from './msg-enum.fixtures'
import msgMaps from './msg-maps.fixtures'
import msgJsonNames from './msg-json-names.fixtures'
import msgProto2Optionals from './msg-proto2-optionals.fixtures'
import msgProto3Optionals from './msg-proto3-optionals.fixtures'
Expand Down Expand Up @@ -551,7 +550,6 @@ export const fixtures = new FixtureRegistry();
fixtures.register(msgOneofs);
fixtures.register(msgScalar);
fixtures.register(msgEnum);
fixtures.register(msgMaps);
fixtures.register(msgJsonNames);
fixtures.register(msgProto2Optionals);
fixtures.register(msgProto3Optionals);
Expand Down
224 changes: 0 additions & 224 deletions packages/test-fixtures/msg-maps.fixtures.ts

This file was deleted.

0 comments on commit 58e1b79

Please sign in to comment.