Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Aral Balkan
@aral@mastodon.ar.al  ·  activity timestamp 2 days ago

Today I learned… if you are doing something naughty in JavaScript* (and let’s face it, of course you are) that TypeScript’s type checker is giving you an error for and you – being you – want to keep being naughty (because you can and that’s half the fun), there’s a better way to silence the error than using @ts-ignore which, umm, just ignores it.

Instead, you can use @ts-expect-error (with the error message, to remind yourself what you’re expecting).

This way, if the error ever goes away (which would likely signal… uh… an error), you will be notified.

So, yeah, how’s your morning going?

* Like returning a proxy from a constructor instead of an instance of the class itself.

#JavaScript #TypeScript #typeChecking #proxy #tsIgnore #tsExpectError

  • Copy link
  • Flag this post
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1-alpha.8 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login