Are you sure you typed sudo apt upgrade and not sudo apt full-upgade or sudo apt dist-upgrade?
If vs code is a .deb package, upgrade would never uninstall it, while full-upgrade or dist-upgrade might.
If vs code isn't a package, then either might break a vs code install due to incompatibilities with upgraded packages (which is one of the downsides of using unpackaged software) - but it won't trigger an uninstall (because as far as apt is concerned, there wouldn't be anything to uninstall).
upgrade will upgrade packages (and install any new dependencies) as long as they don't require any other package to be removed. full-upgrade (aka dist-upgrade) will upgrade packages even if that requires conflicting packages to be removed.
See man apt and man apt-get for details. Here's a relevant short extract from apt's man page, with some highlighting and reformatting:
upgrade (apt-get(8))
upgrade is used to install available upgrades of all packages
currently installed on the system from the sources configured via
sources.list(5). New packages will be installed if required to
satisfy dependencies, but existing packages will never be removed.
If an upgrade for a package requires the removal of an installed
package the upgrade for this package isn't performed.
full-upgrade (apt-get(8))
full-upgrade performs the function of upgrade but will remove
currently installed packages if this is needed to upgrade the
system as a whole.
If you want/need to do a dist-upgrade then you will need to upgrade vs code too, to a version that doesn't conflict with your other packages. This may require waiting for Microsoft to release a new version of the package....or that may have already been released and all you need to do is download and install it. Impossible to tell for sure because you haven't provided any details about package names or versions.
If you know the name of the vs code package and have aptitude installed you can run aptitude why-not packagename to get a hint about what other package(s) might be triggering an uninstall.