News for hackers. Stuff that matters.
Re:Tricks I wish I knew when I learned TypeScript by Etheryte on Tuesday October 12, 2021 @01:56PM (#28842838)
That's fairly subjective and I can see arguments for both sides, in the above example I've gone with the approach the Typescript documentation itself gives which uses any. Given the parameter is only used as an input, using any and unknown are interchangeable and there is no difference in this specific case.
Re:Tricks I wish I knew when I learned TypeScript by wdfx on Tuesday October 12, 2021 @02:02PM (#28842942)
I somewhat agree, but to me the semantics using unknown makes more sense as the function is attempting to answer a question of the input object.

"What is object? I don't know. Does it meet these conditions? Yes then object is Human else not."

Re:Tricks I wish I knew when I learned TypeScript by Etheryte on Tuesday October 12, 2021 @02:45PM (#28843471)
While I see where you're coming from, semantic formulation like this is highly subjective. All the same the problem statement could be "Given any kind of input, tell me whether it's a Human or not".