Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You asked for isInteger to work as a type guard and I showed you how. If you prefer explicit casts everywhere that's fine, but it isn't a type guard. You could even use the type anonymously if you really want: (n is number & {Symbol(): never}).

Whatever floats your boat, as you say.



Oh boy, I never ever asked for a replacement for Number.isInteger! I prefer to use native functions.

Have a nice day.


Then alter the type of the ambient native function itself:

    interface NumberConstructor {
      isInteger(n: unknown): n is number & { Symbol(): never }
    }




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: