To understand this more specifically, if someone write some piece of code that accepts objects of type Model based on the above class in the article, f.e. some code like
letarray:Model[]=[]// push some models into the array, including Animal// instances, then later:constcol:string=array[2].idColumn
this code is going to fail if it unexpectedly receives string | string[] because it is expecting to have a string only, and may call string-specific methods on that string, etc.
As you can see here, this doesn't have to do with classes vs functions at all. Definitely use only functions if you like that, but this problem still needs to be taken into account, and it is simply about assignment.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
To understand this more specifically, if someone write some piece of code that accepts objects of type
Model
based on the above class in the article, f.e. some code likethis code is going to fail if it unexpectedly receives
string | string[]
because it is expecting to have astring
only, and may call string-specific methods on that string, etc.As you can see here, this doesn't have to do with classes vs functions at all. Definitely use only functions if you like that, but this problem still needs to be taken into account, and it is simply about assignment.