-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix type exports and integrate arethetypeswrong
#838
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was tested with
examples-es
using:
- react/esbuild (ESM with esbuild)
- react/rollup (ESM with rollup)
- react/webpack (ESM with webpack)
- react/webpack-cjs (CJS with webpack)
That's great, now we know that bundlers work as expected with the changed exports.
But besides bundlers, Node.js and TypeScript also resolve modules. I wonder how well attw
guards against mistakes in our exports for the three different consumers. It would be really nice to know what is covered and what isn't. Can we find out?
Were you able to reproduce #679 and confirm that it's fixed with this? |
I ran some tests on a branch in I also did this same test with a file I'm not sure if this answers your question or provides sufficient confidence that this works for Node and TS. Let me know though. |
Nice. I suppose with scripts like these? t.mjsimport { ConnectError as a} from "@connectrpc/connect";
import { createFetchClient as b } from "@connectrpc/connect/protocol";
import { createTransport as c } from "@connectrpc/connect/protocol-grpc";
import { createTransport as d } from "@connectrpc/connect/protocol-grpc-web";
import { createTransport as e } from "@connectrpc/connect/protocol-connect";
const ok = !!a && !!b && !!c && !!d && !!e;
console.log(ok ? "ok" : "fail") t.cjsconst { ConnectError: a } = require("@connectrpc/connect");
const { createFetchClient: b } = require("@connectrpc/connect/protocol");
const { createTransport: c } = require("@connectrpc/connect/protocol-grpc");
const { createTransport: d } = require("@connectrpc/connect/protocol-grpc-web");
const { createTransport: e } = require("@connectrpc/connect/protocol-connect");
const ok = !!a && !!b && !!c && !!d && !!e;
console.log(ok ? "ok" : "fail") Running both scripts with Node.js LTS from v10 to v20 ( Now to break it: $ cd packages/connect
$ npm run build
$ mv protocol.js protocol.js-x
$ npx attw --pack No error from It's a bummer that This makes me wonder: Clearly we have to support Node.js v10 module resolution for types, since it's not uncommon to use So I wonder whether we can actually safely delete
Seems sufficient 👍 The only open questions from my end are #838 (comment) and #838 (comment). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
arethetypeswrong
arethetypeswrong
Our type exports are incorrect for the Node16 module resolution algorithm: When Connect-ES is used with lib checks enabled, TypeScript raises the error TS1479. For a more detailed description, see #679.
This integrates the arethetypeswrong CLI tool for checking types in published packages. It also adds the call to lint the types in CI that it is easy to spot regressions.
This was tested with
examples-es
using: