I'm new to Typescript. I'm stuck at the interfaces part. Using Nodejs I send an object from the client to the server called startData. This object contains an ID and Username. I'm using an interface to define the types in this object. I define testId as a number and Username as a string.
However, when I send for example testId as a string and Username as an object, no error gets thrown. Why does the interface accept the wrong types? I would expect it to throw some kind of unexpected type error.
interface startDataInterface{
testId: number;
username: string;
}
socket.on('startData', function(startData: startDataInterface) {
...
I'm sending this on the client:
socket.emit('startData', {testId: "string", username: {}});