For someone trying to get this to work and hitting the same problem, I only managed to get the initializer to work by placing is it in a different folder than indicated.
This didn’t work for me:
but using this path instead worked for me
// javascripts/discourse/pre-initializers/extend-user-for-my-plugin.js
Kudos to @Lilly for providing the hint by linking to a sample code of a pre-initializer
.