arethetypeswrong.github.io: Can I run `npx arethetypeswrong` (CLI for library authors)

Can I run npx are-the-types-wrong in my library, or pointed to a package.json, or to an npm URL, or a project, and

be told if I am doing it right

so I don’t have to read that long README.md 🙈

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 25 (4 by maintainers)

Most upvoted comments

@arethetypeswrong/cli is published 🥳

Thanks @ej-shafran!

This is fantastic. I think it’s an excellent idea to make use of TypeScripts understanding of module resolution. Thanks for the work @andrewbranch!

A CLI with a meaningful exit code and the option to ignore violations would be very helpful. I would love to run this in CI, either by giving a path to a package, or by doing an npm pack first myself.

Ignoring violations by ProblemKind, and optionally narrowing to a specific ResolutionKind and entrypoint seems useful.

FYI, a couple weeks ago I was working on a CLI tool that uses the React ink CLI renderer to generate a table equivalent to what’s on the website, with the goal of using it in a GH Action job:

image

I’m picking up with that work now.

Might be something that can be rolled over into an actual attw CLI tool!

Happy to take over if you don’t mind. It’d be a few days before I can get to it too but I think this would be immensely useful!

@ej-shafran’s PR at #26 looks really awesome! I just put up my initial review with some suggestions about config options and thoughts on --ignore. I’d encourage anyone interested in using it to take a look and weigh in if you have feedback!

@markerikson wish I’d seen that this morning 😆

I’ve opened a WIP PR with what I’ve done already - I’ll take a look at your work when I have a minute and see what I can apply from it

Yeah, I’m pretty sure that the code I’ve got in https://github.com/reduxjs/redux-toolkit/tree/master/examples/publish-ci/are-the-types-wrong can be turned into both a standalone CI tool and a Github Action pretty straightforwardly!

But someone else needs to do it 😃 I’ve got entirely too many other things on my mind atm.

I just got this working, and added it to Redux Toolkit’s “check published artifact in CI” job:

https://github.com/reduxjs/redux-toolkit/pull/3294

edit

And now I’ve got that suite of examples being used over in the redux-thunk repo as well, including the attw check:

https://github.com/reduxjs/redux-thunk/pull/342

No, but I’d like to make a CLI eventually.

Here is a small piece of code that does the analysis on a package in the local file system instead of a tarball: https://gist.github.com/timostamm/3797825096a418b1f4c97d979e2d4ae7

Running npm pack sure has advantages, but I figured it might be easier to get started with this (and not have to think about different package managers).

This has helped me so much already. I still got quite a few question marks around how things work in some scenarios, for instance that which @markerikson is also describing with publishing of CJS & ESM in parallel. My situation is slightly different though because I’m trying to stay as close as possible to tsc and avoid bundlers entirely (ultimately, I still believe (or hope?) that libraries generally just don’t (or shouldn’t) need bundlers at all).

Anyways, thanks for putting this together @andrewbranch and for starting that CLI @markerikson. I can’t promise when I can get to it yet (probably right after easter), but I’ll definitely turn this into a github action & standalone cli. Will report back here.

Have you seen the web UI of this project? clack looks way too pretty 🤪

You can run the CLI in a local project like this:

npx @arethetypeswrong/cli $(npm pack)

This seems to work in a Linux shell but also Windows PowerShell (haven’t tried any others).

A nice improvement would be to automate the npm pack step and maybe also the removal of the created package file.

Thank you for the work on this 😃

@mesqueeb I do think adding something to the README would be nice, but for the meanwhile you can look at the packages/cli folder, or just:

https://www.npmjs.com/package/@arethetypeswrong/cli

@andrewbranch will you add something to the readme ? I’d love to know how to use the CLI : )