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
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?
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.
So what type is
80 + 1? This all appears to be subtyping which I always find difficult to grok.80 + 1is not a literal, but a binary expression. A variable initialized with this value is of typenumber. Literal types will only be used for variables initialized with a literal:But
80 + 1has a type, and80has a type and1has a type, so does80have+defined for it? Does it have implicit conversion from type80to typenumber?The compiler automatically widens literal types if necessary. Adding two expressions of a numeric literal type or type
numberproduces a value of typenumber.