The compass releases your greatest fear, which in Jack Sparrow's case is Salazar
40 minutes into Pirates of the Caribbean: Salazar's Revenge (2017), Captain Hector Barbossa visits a bald witch, Shansa, to consult with her for a solution to his problem of undead sailors having "taken command of the sea".
Once Barbossa confirms that his treasure is "worth dying for", Shansa reveals some information about the compass:
SHANSA: Jack held a compass which points you to the thing
you desire most.
But, betray the compass...
And it releases your greatest fear.
—Pirates of the Caribbean: Salazar's Revenge (2017)
The compass is not linked to Salazar or his curse in any special way, except that Jack's greatest fear, at the time of betraying it, happened to be Salazar.
This becomes even more clear when we take a look at the flashback scene in which we see Jack being given the compass by his former captain, Captain Morgan:
MORGAN: It's up to you now, Jack. This compass points towards what you want most. Never betray it.
—Pirates of the Caribbean: Salazar's Revenge (2017)
Morgan had this magical compass and was aware of its special relationship (never to betray it) before Salazar was ever destroyed at the Devil's Triangle, and before Salazar was cursed, so it makes no sense that it would have an inherent, special relationship to one particular curse that would happen in the future, long after the inception of the magical compass.