Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Aral Balkan
Aral Balkan
@aral@mastodon.ar.al  ·  activity timestamp 3 weeks 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
Teacher Muhammad Hussein
Teacher Muhammad Hussein
@MohammedHusein@mastodon.social replied  ·  activity timestamp 3 weeks ago

@aral I just had a video chat to get the verification sticker

  • Copy link
  • Flag this comment
  • Block
Gerard
Gerard
@germorfor@xarxa.cloud replied  ·  activity timestamp 3 weeks ago

@aral I thought slapping "any" on it was the go-to for typescript type shenanigans 🤣

  • Copy link
  • Flag this comment
  • Block
Claudius
Claudius
@claudius@darmstadt.social replied  ·  activity timestamp 3 weeks ago

@aral extraneous expect exception. exiting.

  • Copy link
  • Flag this comment
  • Block

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.44 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct