Hacker News new | past | comments | ask | show | jobs | submit
Re: __proto__, it's addressed in TFA

> Note that __proto__ also exists as a getter and a setter in Object.prototype. This feature is deprecated in favor of Object.getPrototypeOf() and Object.setPrototypeOf(). However, that is different from using this name in an object literal – which is not deprecated.

Thanks for the reply. I was not aware of this.

In this case, I could write this:

  type Activation = "Active" | "Inactive";
  const Activation = {
    __proto__: null,
    Active: "Active",
    Inactive: "Inactive",
  } as { [K in Activation]: K };
This completely hides `__proto__` and avoid using utility types like `Exclude`.

Note that it is safe because TypeScript checks that the type assertion is valid. If I mistype a value, TypeScript will complain about the assertion.