Closed wSedlacek closed 4 years ago
I added a test and changed a few things so the test would pass.
Using globalThis will require upgrading to TypeScript 3.4 or higher. Is there a reason we are still using TypeScript 2.9.2? Just for compatibility or something else?
It's for compatibility.
Granted pre-3.0 stuff is largely outdated, but 3.4 is a fairly high requirement at the moment (people stuck on old angular versions for instance may have to invest a lot of effort to migrate to newer versions and get access to TS3.4). If there's a way to be compatible with a wider range of versions I'd prefer that.
Are you sure the solution used in the current register.ts doesn't work when node.js typings are absent?
You do get an error if "node"
is not included in the typings.
Is there another check we could run other then typeof global === 'undefined'
?
Would this work?
export const ctx = this;
ctx.Override = () => () => {
// noop
};
Finally got it to pass with types
not including node by setting global
with this line
declare var global: NodeJS.Global;
I think I am finally happy with this and it should be backwards compatible. Let me know if you want me to change anything else.
Cleaned up commit history
Making a library is a lot harder then working on your own project 😅 Thanks for bearing with me!
Fixes #28