15

This question asks about TypeScript (not TSX).

The 2nd highest rated answer originally suggested using (<any>window).MyNamespace.

The 3rd highest rated answer was always suggesting to use (window as any).MyNamespace.

One user edited the 2nd highest answer to match the exact syntax of the 3rd highest answer. His logic for doing so was because "[the] syntax is just an old, legacy syntax ..." and "it seems bad for the top voted answer to use the worse syntax" (even though it's not the top voted answer).

Am I wrong in arguing that the 2nd highest answer should not be changed to match the 3rd highest rated answer? It seems like it defeats the purpose of posting answers and voting (what's the point of posting a more correct answer if someone can just change the existing highest answer to the new answer?)

In this case, the second answer explicitly targets TSX as well, so there are more degrees of separation at play.

I'd also imagine over time the 3rd highest answer will get enough votes to surpass the 2nd answer which has the older (but not wrong) syntax.

As a compromise, I added a note to the 2nd highest answer stating that for TSX, the other answer should be used. This did not satisfy the other editor though.

3
  • 33
    As a general point here - can we please stop destroying knowledge? The point of SO is to collect it. Just because an older solution exists, doesn't mean it has to be excised. If there are already two solutions A and B and you think one of them is better then use your votes for that. Don't just eliminate the other one.
    – VLAZ
    Commented Nov 1, 2021 at 6:21
  • 6
    Another SME here - although the old syntax is not recommended, it is not deprecated and is still a perfectly valid syntax. The initial edit was incorrect
    – 0Valt
    Commented Nov 1, 2021 at 11:37
  • 1
    Related: Wrong usage of the [tsx] tag Commented Nov 1, 2021 at 12:05

1 Answer 1

-3

Why not both edits? The answer could contain both the legacy, more-unique code and the newer code similar to that of the 3rd answer, with a comment that the older code is outdated and the newer code is recommended. This simultaneously retains the older knowledge whilst addressing the issue of having up-to-date answers.

5
  • 2
    Counterpoint: why combine two answers into one, if there is a perfectly good second answer for that? Is the aim to only have one single answer which is an amalgamation of every possible solution?
    – VLAZ
    Commented Nov 1, 2021 at 19:22
  • 1st question: to deal with issue of legacy. 2nd question: no, this was only in the case of legacy, since I feel that pointing out outdated but otherwise good answers is helpful but shouldn't be relied on
    – MBorg
    Commented Nov 2, 2021 at 0:14
  • 1
    "to deal with issue of legacy" OK, let's be absolutely clear - in this case, there is no "legacy syntax". Nothing outdated, nothing obsolete, nothing deprecated. The two alternatives are perfectly acceptable in TS code and a matter of personal choice. There is only ambiguity when using <> with JSX/TSX grammar which is why as was introduced to resolve it. Thus as is newer but I can't say there is "issue of legacy" here because there is no issue of using either of these in regular TS code.
    – VLAZ
    Commented Nov 2, 2021 at 6:26
  • With this said, there is Introducing Outdated Answers project underway to resolve the general case of outdated approaches. I'd rather not mangle answers together just in order to piggyback on the existing ranking. Especially not if it introduces wrong information like "this solution is not good any more" when that's not the case.
    – VLAZ
    Commented Nov 2, 2021 at 6:29
  • Apologies; I was of the impression that the code was outdated. In that case, I don't see the need for the edit. At most, a comment stating the answer is old syntax 'but still viable' and maybe a link to an answer with a newer syntax in case one wanted to use the newest syntax, but I don't consider it needed if it still works.
    – MBorg
    Commented Nov 2, 2021 at 6:40

Not the answer you're looking for? Browse other questions tagged .