2 ms·
Oh, yeah, that feature's existed for years; it's called "user-defined type guards". https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defin
by Zarel 8y ago
Oh, yeah, that feature's existed for years; it's called "user-defined type guards".
https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards https://www.typescriptlang.org/docs/handbook/advanced-types....
Unfortunately, it doesn't work in `checkJs` mode, and I always wish I could do it inline.