I need to rewrite my tampermonkey script on typescript.
What is correct way to rewrite this javascript on typescript?
if (window.top != window.self ) {
return;
}
Main goal is to stop executing script if it's running not in window.top.
Typescript compiler write ERROR TS1108: A 'return' statement can only be used within a function body.
You cannot return outside function, but using throw Exception you can stop execution userscipts (tampermonkey) too:
if (window.top != window.self) {
throw new Error("Not on top");
}