Skip to content

docs: blog post on Avoiding anys with Linting and TypeScript #10362

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

Merged

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Nov 20, 2024

PR Checklist

Overview

Walks through how anys can sneak in even with noImplicitAny, then our suite of rules, as well as some other useful helpers.

I'm having a bit of writer's block trying to write friendly prose here. If anybody can suggest how to make the writing more approachable, I'd appreciate it.

💖

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Nov 20, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 6ed0cb0
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/678e5bcd9eb98b0008a2840b
😎 Deploy Preview https://deploy-preview-10362--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

nx-cloud bot commented Nov 20, 2024

View your CI Pipeline Execution ↗ for commit 6ed0cb0.

Command Status Duration Result
nx test eslint-plugin --coverage=false ✅ Succeeded 7m 33s View ↗
nx test eslint-plugin ✅ Succeeded 5m 57s View ↗
nx test typescript-eslint ✅ Succeeded 4s View ↗
nx test visitor-keys ✅ Succeeded <1s View ↗
nx test type-utils ✅ Succeeded <1s View ↗
nx run types:build ✅ Succeeded <1s View ↗
nx test utils ✅ Succeeded <1s View ↗
nx test typescript-estree ✅ Succeeded <1s View ↗
Additional runs (24) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-01-20 14:42:39 UTC

</TabItem>
</Tabs>

One the types for `@example/package` are fixed to no longer produce a type error, the comment directive will itself produce a type error asking to delete itself.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this blog post should explain how // @ts-expect-error / // @ts-ignore work. I think that'd be better served in a separate post on a TypeScript-dedicated page.

I haven't found one online I truly like so I might just put it on learningtypescript.com... the ideal state would be to have a dedicated page on the first-party typescriptlang.org docs IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LearningTypeScript/site#143

It's blocked on eslint/eslint.org#664, and I don't think it's horrible if we don't include a link to it in the blog post. 🤷

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.15%. Comparing base (a175189) to head (8f77f28).
Report is 22 commits behind head on main.

Current head 8f77f28 differs from pull request most recent head 6ed0cb0

Please upload reports for the commit 6ed0cb0 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10362      +/-   ##
==========================================
+ Coverage   87.00%   87.15%   +0.15%     
==========================================
  Files         447      448       +1     
  Lines       15586    15578       -8     
  Branches     4542     4551       +9     
==========================================
+ Hits        13560    13577      +17     
+ Misses       1671     1645      -26     
- Partials      355      356       +1     
Flag Coverage Δ
unittest 87.15% <ø> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 88 files with indirect coverage changes

@JoshuaKGoldberg JoshuaKGoldberg changed the title [WIP] docs: blog post on catching any docs: blog post on catching any Jan 2, 2025
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review January 2, 2025 09:30
Co-authored-by: YeonJuan <yeonjuan93@naver.com>
Copy link
Member

@ronami ronami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing 💯

Comment on lines 200 to 201
`// @ts-expect-error` and `// @ts-ignore` are almost the same, except `// @ts-expect-error` will produce a new type error if its line doesn't already have one.
It's generally preferable to use `// @ts-expect-error` over `// @ts-ignore`.
Copy link
Member

@ronami ronami Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's too niche to mention, but the error type (which can be created using the ignore directives) also counts as an any.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, yeah, I think I'll skip that morass of confusing API nuances...

JoshuaKGoldberg and others added 4 commits January 7, 2025 09:21
Co-authored-by: Ronen Amiel <ronen.amiel@gmail.com>
Co-authored-by: Ronen Amiel <ronen.amiel@gmail.com>
ronami
ronami previously approved these changes Jan 7, 2025
Copy link
Member

@ronami ronami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first time I enabled the no-unsafe-* rules, I was shocked at how many anys I had in my code base without even realizing it.

Explaining this better is so important 💯

@JoshuaKGoldberg JoshuaKGoldberg changed the title docs: blog post on catching any docs: blog post on avoiding anys Jan 13, 2025
@JoshuaKGoldberg
Copy link
Member Author

FYI in e62fb94 I also reworked the opening paragraphs a bit. IMO they were too long before.

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Jan 13, 2025
@github-actions github-actions bot removed the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Jan 16, 2025
kirkwaiblinger
kirkwaiblinger previously approved these changes Jan 19, 2025
Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random gif

Co-authored-by: Kirk Waiblinger <53019676+kirkwaiblinger@users.noreply.github.com>
@JoshuaKGoldberg
Copy link
Member Author

👍 I set the date for this to be tomorrow, the 21st, since today is a holiday in the US. I can manually deploy in the morning.

@JoshuaKGoldberg JoshuaKGoldberg merged commit 55bed75 into typescript-eslint:main Jan 21, 2025
59 of 60 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the blog-post-catching-any branch January 21, 2025 14:43
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blog: Write a blog post on no-unsafe-* rules
4 participants