Hacker News new | ask | show | jobs
by agentcooper 2334 days ago
This is not correct. Following example is valid in strict TypeScript:

  interface Dog {
    breed: string;
  }
  const dog = {} as Dog;
  console.log(dog.breed);
Using `as` is very unsafe in TypeScript.

I've collected more quirks of `as` in this playground: https://www.typescriptlang.org/play/index.html#code/PTAEAMEs...