supermacro / neverthrow

Type-Safe Errors for JS & TypeScript
MIT License
4.03k stars 84 forks source link

Added arethetypeswrong to check built outputs #569

Open mattpocock opened 3 months ago

changeset-bot[bot] commented 3 months ago

⚠️ No Changeset found

Latest commit: 734f695d79503d2ddc5205386ffb889d4ce5cca4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

mattpocock commented 2 months ago

@dmmulroy attw was built by Andrew Branch of the TS team, the doyen of modules and exports. It's extremely useful for checking if the exported types are correct in the package.json. I wanted to add it to make sure that my tsup changes weren't breaking anything.

supermacro commented 2 months ago

This package / pr is still not clicking with respect to the bigger picture PR of https://github.com/supermacro/neverthrow/pull/570

In my head I am asking myself, "why do I need @arethetypeswrong/cli if we already have tsc doing typechecking that short-circuits on a typeerror".

It's extremely useful for checking if the exported types are correct in the package.json. I wanted to add it to make sure that my tsup changes weren't breaking anything.

So this makes me think that this PR is purely here to ascertain that the change from rollup --> tsup is working as expected and nothing else, correct?


Edit: Would there be value in keeping this longer term or would this just be useful in the near-term as a tool to help with a smooth transition.

mattpocock commented 2 months ago

@supermacro

tsc and attw do different things. tsc checks that your code type checks. attw checks that other packages consuming your code can consume it. It prevents errors like mis-configuring exports.

More info in this article.

You're right, it is partially a bridging PR to ensure that tsup makes no meaningful changes.

But it does have its own utility. In the future, you may want to consider adding multiple entrypoints to neverthrow to prevent the downsides of barrel files. attw would ensure that exports would still be configured correctly.

Overall, I like as much of the user experience as possible to be testable via CI. Checking that users can consume the code feels important. But if you don't want it checked on every CI run, I can understand that.

dmmulroy commented 1 month ago

I think that this is positive change - @supermacro and @m-shaka could we adopt this and merge it to unblock #570?