Proposal: https://github.com/tc39/proposal-global
I don't think libdef can solve it?
Also what type top-level this should have?
I don't think libdef can solve it?
Seems like even global is defined simply as any value: https://github.com/facebook/flow/blob/fa89aadb55ae9bb37c71e14d7274935903d501ce/lib/core.js#L835
Are there any consequences of doing the same with globalThis or can I send a PR?
I think it is wrong approach for this, there should be some declare global like TypeScript have?
// `this` is undefined in module scope
this.a = 1
globalThis.a = 1
a // 1
a = 'hello'
globalThis.a // 'hello'
this.a // 'hello' or error in module scope
window.a // 'hello'
I understand it's not ideal but the same applies to already existing global. It would be ideal to have a better solution but I am afraid it can take quite a long time to get there. :)
I'm just against typing it as any, there's already too much any in libdefs
@mrtnzlml I created PR for globalThis
@goodmind Thank you for the PR! :) Would it be possible to do something like this even for global (to fix the any type)?
Most helpful comment
@mrtnzlml I created PR for globalThis