-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: expose Console on global object [don't merge] #2856
Conversation
Can you add a test of some sort? |
I added the test case it fails with error described above. |
Ah, yeah, the unique symbol thing... this recently crept up in the TypeScript repo, I can't remember the specific issue number, but TypeScript always emits |
Also, hopefully in TypeScript 2.7 there will be support for a form of nominal typing which will use symbol branding, so we would likely want to adjust to that in the future, because that is essentially what we are trying to express here is a nominal type versus a structural one. |
Even so, Type |
So the only easy way is to have just an interface then and guard based on that interface and keep the actual classes/types internal. This does highlight though that we do need to try to get back to a generated type library fairly quickly because trying to keep this in sync with code is going be not fun. |
ac04be7
to
5afed50
Compare
I think I figured it out - instead of exporting I exposed it on global object as it should be. @kitsonk @justjavac please review |
That breaks the browser compatibility rule. |
@nayeemrmn why is that? MDN tells that it's exposed on global (or |
@bartlomieju Isn't this about the made up |
Alright, my bad, now I see what you mean. I'll think about it |
I'll revisit this PR after #2868 |
It's useful to export
Console
fromDeno
object. Obvious example would be creating "capturing" console for testing module. Unfortunately I hit problem with types in TS which I can't figure on my own.Currently experiencing this problem:
From
lib.deno_runtime.d.ts
:Inside
Console
there isisConsoleInstance
which is a unique symbol. This causes thatDeno.Console.isConsoleInstance
is a different symbol thanconsoleTypes.Console.isConsoleInstance
.I believe the problem lies in a way we generated our declaration file, but I'm not sure. Calling @kitsonk for help on this one.