I was expecting a type matching A, but instead you passed B.
You can assign variables types to give me hints about what kind of types you want to allow in that variable. For instance:
const num: number = 0;
This tells me that num
will always be a number
.
But sometimes, you'll break that pact you made with me. For instance:
const num: number = 'some string';
In your case, you said that this type was the only thing assignable to that variable:
string
And you passed me this instead:
number