5 Matching Annotations
  1. Aug 2021
    1. which seems to resolve the issue for me and makes no casts, ensuring that Typescript can keep doing its good job of widening as much as necessary and narrowing as much as possible without me having to claim I know better than the compiler. I'm posting it here since it doesn't seem to have been mentioned anywhere.

      makes no casts, ensuring that Typescript can keep doing its good job of widening as much as necessary and narrowing as much as possible without me having to claim I know better than the compiler.

    2. I think a more natural/appropriate behavior for type signature of includes would be for the literal types to be widened.
    1. This type of assertion causes the compiler to infer the narrowest type possible for a value, including making everything readonly.

      "infer"?

    2. One problem is the literal ['a','b','c'] will be inferred as type string[], so the type system will forget about the specific values.
    3. t's not supposed to work with that, since by the time you do const xs = ['a','b','c'] the compiler has already widened xs to string[] and completely forgotten about the specific values.