1. 11
  1.  

  2. 2

    So what type is 80 + 1? This all appears to be subtyping which I always find difficult to grok.

    1. 3

      80 + 1 is not a literal, but a binary expression. A variable initialized with this value is of type number. Literal types will only be used for variables initialized with a literal:

      const x = 80;  // Type 80
      const y = 80 + 1;  // Type number
      
      1. 1

        But 80 + 1 has a type, and 80 has a type and 1 has a type, so does 80 have + defined for it? Does it have implicit conversion from type 80 to type number?

        1. 3

          The compiler automatically widens literal types if necessary. Adding two expressions of a numeric literal type or type number produces a value of type number.