We're trying to write a script to run standalone in a web browser, inside a script tag, and it's not a module.
However, there are some globals that are made available by other scripts, that we want to have typechecked by TypeScript.
Right now, we're using import type, specifically importing the type, then using declare const ... to declare the presence of the global in the surrounding environment.
However, using import type at all seems to cause TSC to conclude that our standalone script that only accesses global variables is somehow an ES module. It then randomly adds stuff to our script that crashes it at runtime and prevents it from working.
TSC emits Object.defineProperty(exports, "__esModule", { value: true });, but exports does not exist. Because the script is not a dang module. And we can't find any way to turn this off, or any alternative to import type that allows us to properly include the type definitions for the globals that already exist, that we're not importing because this is 100% not a module.
Is there any way to include these type definitions without becoming a module, or a way to stop TSC from emitting code that literally crashes when we run the code standalone and not in a module? Because it's not a module, and it shouldn't be a module.
type="module" on the script tag is an okay workaround, but we're upset with TypeScript deciding that our code is a module in the first place, because it's not. It's literally not a module and we really need TSC to see that. How?