This is not dependent on compiler settings.
declare global is used inside a file that has
export to declare things in the global scope. This is necessary in files that contain
export since such files are considered modules, and anything declared in a module is in the module scope.
declare global in a file that is not a module (that is contains no
export) is an error since everything in such a file is in the global scope anyway.