Skip to content

Commit 0037030

Browse files
author
Tate
committed
export MIN_SUPPORTED_VERSION_X
fixes #94.
1 parent de91e2a commit 0037030

File tree

20 files changed

+100
-50
lines changed

20 files changed

+100
-50
lines changed

Diff for: clientcompat/src/clientcompat.pb.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
BinaryWriter,
88
JSONrequest,
99
PBrequest,
10-
// This is the minimum version supported by the current runtime.
11-
// If this line fails typechecking, breaking changes have been introduced and this
12-
// file needs to be regenerated by running `yarn twirpscript`.
13-
MIN_SUPPORTED_VERSION_0_0_34,
1410
} from "twirpscript";
11+
// This is the minimum version supported by the current runtime.
12+
// If this line fails typechecking, breaking changes have been introduced and this
13+
// file needs to be regenerated by running `yarn twirpscript`.
14+
export { MIN_SUPPORTED_VERSION_0_0_34 } from "twirpscript";
1515

1616
//========================================//
1717
// CompatService Protobuf Client //

Diff for: examples/authentication/src/protos/authentication.pb.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
BinaryWriter,
88
JSONrequest,
99
PBrequest,
10-
// This is the minimum version supported by the current runtime.
11-
// If this line fails typechecking, breaking changes have been introduced and this
12-
// file needs to be regenerated by running `yarn twirpscript`.
13-
MIN_SUPPORTED_VERSION_0_0_34,
1410
} from "twirpscript";
11+
// This is the minimum version supported by the current runtime.
12+
// If this line fails typechecking, breaking changes have been introduced and this
13+
// file needs to be regenerated by running `yarn twirpscript`.
14+
export { MIN_SUPPORTED_VERSION_0_0_34 } from "twirpscript";
1515

1616
//========================================//
1717
// Authentication Protobuf Client //

Diff for: examples/authentication/src/protos/haberdasher.pb.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
BinaryWriter,
88
JSONrequest,
99
PBrequest,
10-
// This is the minimum version supported by the current runtime.
11-
// If this line fails typechecking, breaking changes have been introduced and this
12-
// file needs to be regenerated by running `yarn twirpscript`.
13-
MIN_SUPPORTED_VERSION_0_0_34,
1410
} from "twirpscript";
11+
// This is the minimum version supported by the current runtime.
12+
// If this line fails typechecking, breaking changes have been introduced and this
13+
// file needs to be regenerated by running `yarn twirpscript`.
14+
export { MIN_SUPPORTED_VERSION_0_0_34 } from "twirpscript";
1515

1616
//========================================//
1717
// Haberdasher Protobuf Client //

Diff for: examples/authentication/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"jsx": "react-jsx",
44
"module": "commonjs",
55
"moduleResolution": "Node",
6+
"noUnusedLocals": true,
7+
"noUnusedParameters": true,
68
"outDir": "dist",
79
"rootDir": "src",
810
"strict": true,

Diff for: examples/aws-lambda/src/haberdasher.pb.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
BinaryWriter,
88
JSONrequest,
99
PBrequest,
10-
// This is the minimum version supported by the current runtime.
11-
// If this line fails typechecking, breaking changes have been introduced and this
12-
// file needs to be regenerated by running `yarn twirpscript`.
13-
MIN_SUPPORTED_VERSION_0_0_34,
1410
} from "twirpscript";
11+
// This is the minimum version supported by the current runtime.
12+
// If this line fails typechecking, breaking changes have been introduced and this
13+
// file needs to be regenerated by running `yarn twirpscript`.
14+
export { MIN_SUPPORTED_VERSION_0_0_34 } from "twirpscript";
1515

1616
//========================================//
1717
// Haberdasher Protobuf Client //

Diff for: examples/aws-lambda/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"module": "commonjs",
99
"moduleResolution": "Node",
1010
"noEmitOnError": false,
11+
"noUnusedLocals": true,
12+
"noUnusedParameters": true,
1113
"outDir": "dist",
1214
"removeComments": false,
1315
"resolveJsonModule": true,

Diff for: examples/config-dest/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"compilerOptions": {
3-
"jsx": "react-jsx",
43
"module": "commonjs",
54
"moduleResolution": "Node",
5+
"noEmitOnError": false,
6+
"noUnusedLocals": true,
67
"outDir": "dist",
78
"rootDir": ".",
89
"strict": true,

Diff for: examples/config-root/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"compilerOptions": {
3-
"jsx": "react-jsx",
43
"module": "commonjs",
54
"moduleResolution": "Node",
5+
"noUnusedLocals": true,
6+
"noUnusedParameters": true,
67
"outDir": "dist",
78
"rootDir": "src",
89
"strict": true,

Diff for: examples/javascript-fullstack/src/protos/haberdasher.pb.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import {
66
BinaryWriter,
77
JSONrequest,
88
PBrequest,
9-
// This is the minimum version supported by the current runtime.
10-
// If this line fails typechecking, breaking changes have been introduced and this
11-
// file needs to be regenerated by running `yarn twirpscript`.
12-
MIN_SUPPORTED_VERSION_0_0_34,
139
} from "twirpscript";
10+
// This is the minimum version supported by the current runtime.
11+
// If this line fails typechecking, breaking changes have been introduced and this
12+
// file needs to be regenerated by running `yarn twirpscript`.
13+
export { MIN_SUPPORTED_VERSION_0_0_34 } from "twirpscript";
1414

1515
//========================================//
1616
// Haberdasher Protobuf Client //

Diff for: examples/server-to-server/src/protos/haberdasher.pb.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
BinaryWriter,
88
JSONrequest,
99
PBrequest,
10-
// This is the minimum version supported by the current runtime.
11-
// If this line fails typechecking, breaking changes have been introduced and this
12-
// file needs to be regenerated by running `yarn twirpscript`.
13-
MIN_SUPPORTED_VERSION_0_0_34,
1410
} from "twirpscript";
11+
// This is the minimum version supported by the current runtime.
12+
// If this line fails typechecking, breaking changes have been introduced and this
13+
// file needs to be regenerated by running `yarn twirpscript`.
14+
export { MIN_SUPPORTED_VERSION_0_0_34 } from "twirpscript";
1515

1616
//========================================//
1717
// Haberdasher Protobuf Client //

Diff for: examples/server-to-server/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"compilerOptions": {
33
"module": "commonjs",
44
"moduleResolution": "Node",
5+
"noUnusedLocals": true,
6+
"noUnusedParameters": true,
57
"outDir": "dist",
68
"rootDir": "src",
79
"strict": true,

Diff for: examples/typescript-fullstack/src/protos/haberdasher.pb.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
BinaryWriter,
88
JSONrequest,
99
PBrequest,
10-
// This is the minimum version supported by the current runtime.
11-
// If this line fails typechecking, breaking changes have been introduced and this
12-
// file needs to be regenerated by running `yarn twirpscript`.
13-
MIN_SUPPORTED_VERSION_0_0_34,
1410
} from "twirpscript";
11+
// This is the minimum version supported by the current runtime.
12+
// If this line fails typechecking, breaking changes have been introduced and this
13+
// file needs to be regenerated by running `yarn twirpscript`.
14+
export { MIN_SUPPORTED_VERSION_0_0_34 } from "twirpscript";
1515

1616
//========================================//
1717
// Haberdasher Protobuf Client //

Diff for: examples/typescript-fullstack/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"jsx": "react-jsx",
44
"module": "commonjs",
55
"moduleResolution": "Node",
6+
"noUnusedLocals": true,
7+
"noUnusedParameters": true,
68
"outDir": "dist",
79
"rootDir": "src",
810
"strict": true,

Diff for: src/autogenerate/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -464,15 +464,16 @@ ${printIfTypescript(
464464
import {
465465
BinaryReader,
466466
BinaryWriter
467+
${hasServices ? `,\nJSONrequest,\nPBrequest` : ""}} from 'twirpscript';
467468
${
468469
hasServices
469-
? `,\nJSONrequest,\nPBrequest,
470+
? `\
470471
// This is the minimum version supported by the current runtime.
471472
// If this line fails typechecking, breaking changes have been introduced and this
472473
// file needs to be regenerated by running \`yarn twirpscript\`.
473-
\n${RUNTIME_MIN_CODE_GEN_SUPPORTED_VERSION}`
474+
export { ${RUNTIME_MIN_CODE_GEN_SUPPORTED_VERSION} } from "twirpscript";`
474475
: ""
475-
}} from 'twirpscript';
476+
}
476477
477478
${imports
478479
.map(

Diff for: src/node/test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { nodeHttpTransport } from ".";
33
import { createServer, IncomingMessage, ServerResponse } from "http";
44
import { RpcTransportOpts } from "../runtime/client";
55

6-
const server = jest.fn((req: IncomingMessage, res: ServerResponse) => {
6+
const server = jest.fn((_req: IncomingMessage, res: ServerResponse) => {
77
res.writeHead(200, {});
88
res.end("");
99
});

Diff for: src/test-protos/__snapshots__/test.ts.snap

+16-16
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ import {
217217
BinaryWriter,
218218
JSONrequest,
219219
PBrequest,
220-
// This is the minimum version supported by the current runtime.
221-
// If this line fails typechecking, breaking changes have been introduced and this
222-
// file needs to be regenerated by running \`yarn twirpscript\`.
223-
MIN_SUPPORTED_VERSION_0_0_34,
224220
} from \\"twirpscript\\";
221+
// This is the minimum version supported by the current runtime.
222+
// If this line fails typechecking, breaking changes have been introduced and this
223+
// file needs to be regenerated by running \`yarn twirpscript\`.
224+
export { MIN_SUPPORTED_VERSION_0_0_34 } from \\"twirpscript\\";
225225

226226
import { ImportMessage, ImportEnum } from \\"./unittest_import.pb\\";
227227
import { PublicImportMessage } from \\"./unittest_import_public.pb\\";
@@ -11716,11 +11716,11 @@ import {
1171611716
BinaryWriter,
1171711717
JSONrequest,
1171811718
PBrequest,
11719-
// This is the minimum version supported by the current runtime.
11720-
// If this line fails typechecking, breaking changes have been introduced and this
11721-
// file needs to be regenerated by running \`yarn twirpscript\`.
11722-
MIN_SUPPORTED_VERSION_0_0_34,
1172311719
} from \\"twirpscript\\";
11720+
// This is the minimum version supported by the current runtime.
11721+
// If this line fails typechecking, breaking changes have been introduced and this
11722+
// file needs to be regenerated by running \`yarn twirpscript\`.
11723+
export { MIN_SUPPORTED_VERSION_0_0_34 } from \\"twirpscript\\";
1172411724

1172511725
import { ImportMessage, ImportEnum } from \\"./unittest_import.pb\\";
1172611726
import { PublicImportMessage } from \\"./unittest_import_public.pb\\";
@@ -23280,11 +23280,11 @@ import {
2328023280
BinaryWriter,
2328123281
JSONrequest,
2328223282
PBrequest,
23283-
// This is the minimum version supported by the current runtime.
23284-
// If this line fails typechecking, breaking changes have been introduced and this
23285-
// file needs to be regenerated by running \`yarn twirpscript\`.
23286-
MIN_SUPPORTED_VERSION_0_0_34,
2328723283
} from \\"twirpscript\\";
23284+
// This is the minimum version supported by the current runtime.
23285+
// If this line fails typechecking, breaking changes have been introduced and this
23286+
// file needs to be regenerated by running \`yarn twirpscript\`.
23287+
export { MIN_SUPPORTED_VERSION_0_0_34 } from \\"twirpscript\\";
2328823288

2328923289
import { ImportMessage, ImportEnum } from \\"./unittest_import.pb\\";
2329023290
import { PublicImportMessage } from \\"./unittest_import_public.pb\\";
@@ -36766,11 +36766,11 @@ import {
3676636766
BinaryWriter,
3676736767
JSONrequest,
3676836768
PBrequest,
36769-
// This is the minimum version supported by the current runtime.
36770-
// If this line fails typechecking, breaking changes have been introduced and this
36771-
// file needs to be regenerated by running \`yarn twirpscript\`.
36772-
MIN_SUPPORTED_VERSION_0_0_34,
3677336769
} from \\"twirpscript\\";
36770+
// This is the minimum version supported by the current runtime.
36771+
// If this line fails typechecking, breaking changes have been introduced and this
36772+
// file needs to be regenerated by running \`yarn twirpscript\`.
36773+
export { MIN_SUPPORTED_VERSION_0_0_34 } from \\"twirpscript\\";
3677436774

3677536775
import { ImportMessage, ImportEnum } from \\"./unittest_import.pb\\";
3677636776
import { PublicImportMessage } from \\"./unittest_import_public.pb\\";

Diff for: src/test-serialization/message.pb.ts

+22
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import { BinaryReader, BinaryWriter } from "../../src";
99
// Types //
1010
//========================================//
1111

12+
export type Baz = typeof Baz[keyof typeof Baz];
13+
1214
export interface Foo {
1315
field_one: number;
1416
field_two: Record<string, number | undefined>;
1517
field_three: Bar[];
1618
field_four: Bar;
1719
field_five: number[];
20+
field_six: Baz;
21+
field_seven: Baz[];
1822
}
1923

2024
export interface Bar {
@@ -27,6 +31,8 @@ export interface Bar {
2731
// Protobuf Encode / Decode //
2832
//========================================//
2933

34+
export const Baz = { FOO: 0, BAR: 1 } as const;
35+
3036
export const Foo = {
3137
/**
3238
* Serializes a Foo to protobuf.
@@ -52,6 +58,8 @@ export const Foo = {
5258
field_three: [],
5359
field_four: Bar.initialize(),
5460
field_five: [],
61+
field_six: 0,
62+
field_seven: [],
5563
};
5664
},
5765

@@ -82,6 +90,12 @@ export const Foo = {
8290
if (msg.field_five?.length) {
8391
writer.writeRepeatedInt32(5, msg.field_five);
8492
}
93+
if (msg.field_six) {
94+
writer.writeEnum(6, msg.field_six);
95+
}
96+
if (msg.field_seven?.length) {
97+
writer.writeRepeatedEnum(7, msg.field_seven);
98+
}
8599
return writer;
86100
},
87101

@@ -133,6 +147,14 @@ export const Foo = {
133147
msg.field_five.push(reader.readInt32());
134148
break;
135149
}
150+
case 6: {
151+
msg.field_six = reader.readEnum() as Baz;
152+
break;
153+
}
154+
case 7: {
155+
msg.field_seven.push(reader.readEnum() as Baz);
156+
break;
157+
}
136158
default: {
137159
reader.skipField();
138160
break;

Diff for: src/test-serialization/message.proto

+7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ message Foo {
66
repeated Bar field_three = 3;
77
Bar field_four = 4;
88
repeated int32 field_five = 5;
9+
Baz field_six = 6;
10+
repeated Baz field_seven = 7;
911
}
1012

1113
message Bar {
1214
string field_one = 1;
1315
map<string, int32> field_two = 2;
1416
repeated int32 field_three = 3;
1517
}
18+
19+
enum Baz {
20+
FOO = 0;
21+
BAR = 1;
22+
}

Diff for: src/test-serialization/test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ describe("Serialization/Deserialization", () => {
1414
"field_two": Object {},
1515
},
1616
"field_one": 0,
17+
"field_seven": Array [],
18+
"field_six": 0,
1719
"field_three": Array [],
1820
"field_two": Object {},
1921
}
@@ -36,6 +38,8 @@ describe("Serialization/Deserialization", () => {
3638
"field_two": Object {},
3739
},
3840
"field_one": 3,
41+
"field_seven": Array [],
42+
"field_six": 0,
3943
"field_three": Array [],
4044
"field_two": Object {},
4145
}
@@ -52,6 +56,8 @@ describe("Serialization/Deserialization", () => {
5256
"field_two": Object {},
5357
},
5458
"field_one": 0,
59+
"field_seven": Array [],
60+
"field_six": 0,
5561
"field_three": Array [],
5662
"field_two": Object {},
5763
}
@@ -111,6 +117,8 @@ describe("Serialization/Deserialization", () => {
111117
},
112118
},
113119
"field_one": 3,
120+
"field_seven": Array [],
121+
"field_six": 0,
114122
"field_three": Array [
115123
undefined,
116124
],

Diff for: tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"module": "commonjs",
99
"moduleResolution": "Node",
1010
"noEmitOnError": false,
11+
"noUnusedLocals": true,
12+
"noUnusedParameters": true,
1113
"outDir": "dist",
1214
"removeComments": false,
1315
"resolveJsonModule": true,

0 commit comments

Comments
 (0)