Skip to content

Commit

Permalink
Run tsc against generated code (connectrpc#214)
Browse files Browse the repository at this point in the history
This makes sure that the generated code doesn't have any finicky TS
errors. This change would have caught connectrpc#209

Also remove workspace designation on example so it can be independently
cloned.
  • Loading branch information
paul-sachs authored Oct 10, 2023
1 parent 9c079bf commit 86bfd75
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/react/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@connectrpc/connect-query": "workspace:*",
"@connectrpc/connect-web": "^1.1.2",
"@connectrpc/protoc-gen-connect-es": "^1.1.2",
"@connectrpc/protoc-gen-connect-query": "workspace:*",
"@connectrpc/protoc-gen-connect-query": "^0.5.1",
"@tanstack/react-query": "^4.35.7",
"@tanstack/react-query-devtools": "^4.35.7",
"@testing-library/jest-dom": "^6.1.3",
Expand Down
19 changes: 16 additions & 3 deletions packages/connect-query/src/create-unary-functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,15 @@ describe("createUnaryFunctions", () => {
expect(onError).toHaveBeenCalledTimes(0);
expect(consoleErrorSpy).not.toHaveBeenCalled();

await sleep(10);
await waitFor(
() => {
expect(result.current.error).toStrictEqual("error");
},
{
timeout: 300,
},
);

expect(result.current.error).toStrictEqual("error");
expect(result.current.isError).toStrictEqual(true);
expect(onError).toHaveBeenCalledTimes(1);
expect(consoleErrorSpy).toHaveBeenCalledWith("error");
Expand Down Expand Up @@ -1191,7 +1197,14 @@ describe("createUnaryFunctions", () => {
expect(onError).toHaveBeenCalledTimes(0);
expect(consoleErrorSpy).not.toHaveBeenCalled();

await sleep(10);
await waitFor(
() => {
expect(result.current.error).toStrictEqual("error");
},
{
timeout: 300,
},
);

expect(result.current.error).toStrictEqual("error");
expect(result.current.isError).toStrictEqual(true);
Expand Down
3 changes: 3 additions & 0 deletions packages/protoc-gen-connect-query/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# A directory that exists solely to hold the result of tsc since --noEmit doesn't discover to protability issue found
# by https://github.com/connectrpc/connect-query-es/issues/209
.type-dump
6 changes: 5 additions & 1 deletion packages/protoc-gen-connect-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
"clean": "rm -rf dist",
"build": "pnpm clean && tsc --project tsconfig.build.json",
"format": "prettier . --write --ignore-path ./.eslintignore && eslint . --fix && license-header",
"generate": "rm -rf snapshots/gen && cd snapshots && buf generate buf.build/connectrpc/eliza:8b8b971d6fde4dc8ba5d96f9fda7d53c"
"generate": "rm -rf snapshots/gen && cd snapshots && buf generate buf.build/connectrpc/eliza:8b8b971d6fde4dc8ba5d96f9fda7d53c",
"test": "tsc --declaration --declarationDir .type-dump --emitDeclarationOnly"
},
"preferUnplugged": true,
"devDependencies": {
"@bufbuild/buf": "1.27.0",
"@bufbuild/protoc-gen-es": "^1.3.3",
"@connectrpc/connect": "^1.1.2",
"@connectrpc/connect-query": "workspace:*",
"@connectrpc/protoc-gen-connect-es": "^1.1.2",
"@tanstack/react-query": "^4.35.7",
"typescript": "^5.2.2"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/protoc-gen-connect-query/snapshots/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ plugins:
opt:
- target=ts+dts+js
- import_extension=none
- ts_nocheck=false
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// @generated by protoc-gen-connect-query v0.5.2 with parameter "target=ts+dts+js,import_extension=none"
// @generated by protoc-gen-connect-query v0.5.2 with parameter "target=ts+dts+js,import_extension=none,ts_nocheck=false"
// @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import {
ConverseRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// @generated by protoc-gen-connect-query v0.5.2 with parameter "target=ts+dts+js,import_extension=none"
// @generated by protoc-gen-connect-query v0.5.2 with parameter "target=ts+dts+js,import_extension=none,ts_nocheck=false"
// @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import {
ConverseRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// @generated by protoc-gen-connect-query v0.5.2 with parameter "target=ts+dts+js,import_extension=none"
// @generated by protoc-gen-connect-query v0.5.2 with parameter "target=ts+dts+js,import_extension=none,ts_nocheck=false"
// @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import {
ConverseRequest,
Expand Down
5 changes: 4 additions & 1 deletion packages/protoc-gen-connect-query/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"extends": "./tsconfig.build.json",
"include": ["src", "snapshots"]
"include": ["src", "snapshots", "./*.config.ts"],
"compilerOptions": {
"lib": ["DOM", "ESNext"]
}
}
11 changes: 10 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 86bfd75

Please sign in to comment.