News for hackers. Stuff that matters.
Re:An introduction to type programming in TypeScript by wruza on Wednesday February 02, 2022 @07:28AM (#30176597)
Typescript’s type narrowing is useful for this exact situation:

  // v is any or unknown
  if (typeof v !== "string") {
    throw new Error("oops")
  }
  // v is now string
You can’t get runtime type correctness by deceiving typescript into it.

There are no comments on this comment yet.