The method itself isn't deprecated, only the format of the function parameters.
Earlier Joomla versions (deprecated):
$doc->addScript($url, $mime, $defer, $async)
Later Joomla versions:
$doc->addScript($url, $options, $attributes)
I'm not sure what the
JHtml deprecation notice is about but it shouldn't affect what you're trying to do.
JUri::root() . 'templates/MY_TEMPLATE/js/file.js'
If this is for an extension if your own and you're importing a file, I'd suggest using the
JHtml approach, as it will allow users to override the file , along with some other additional perks:
Path to your JS file:
JHtml::_('script', 'mod_something/file.js', array('version' => 'auto', 'relative' => true));
Notice that I'm using
'relative' => true so the path can be shortened.
Hope this helps