I want to set the first occurrance of a glossary entry in italics. From this answer to a related question, I got the following MWE:
\documentclass{article}
\usepackage{glossaries}
\makeglossaries
\defglsdisplayfirst[\glsdefaulttype]{\textit{#1}}
\newglossaryentry{term}{name={technical term}, description=\nopostdesc}
\begin{document}
First occurrance of \gls{term}, second occurrance of \gls{term}.
\end{document}
However, it has two problems. First, \defglsdisplayfirst is apparently deprecated, and second, I get unwanted horizontal space when using it:

I have seen similar questions on how to solve this without using \defglsdisplayfirst, but they all concern acronyms. I use both acronyms and other entries which are not acronyms, and I want this to apply to all kinds of glossary entries.
As part of the deprecation warning, it says that I should use \defglsentryfmt instead, but I can't figure out how to use it.