Skip to content
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

Update ts_library_builder to properly handle global types #1854

Closed
bartlomieju opened this issue Feb 28, 2019 · 4 comments
Closed

Update ts_library_builder to properly handle global types #1854

bartlomieju opened this issue Feb 28, 2019 · 4 comments

Comments

@bartlomieju
Copy link
Member

Creating separate issue so it's not forgotten.

As this stands at the moment, it won't flow through to the runtime type library. (If you do deno --types you will see it is missing).

The interface is already a global interface (interface ImportMeta {}) as it has been reserved in the language for a long time. We need to extend this interface in the global scope, which is what happens when it is located in lib.web_assembly.d.ts file as that is simply inlined in the runtime type library, but that isn't the "right" way to do it for extending this in the long term. I think it is better that we put this directly in the globals.ts, the only problem is that we need to change ts_library_builder in the mergeGlobal function to copy over any interfaces there into the type library.

That is a bit complicated, so if you wanted to, just move it back to the web assembly library, and then I can do a follow up PR making the change to ts_library_builder. Otherwise you can try to tackle it. It should be added somewhere around here and needs to be done is iterate over any interfaces, ensuring it weeds out the special global interface and adds those to the target.

Originally posted by @kitsonk in #1835 (comment)

I'll tackle that

@kitsonk
Copy link
Contributor

kitsonk commented Mar 1, 2019

Let me know if you need any help. I don't have all the best availability at the moment though.

@bartlomieju
Copy link
Member Author

@kitsonk I started to work on that, got it almost figured out, one thing that bothers me:
If I put ImportMeta declaration in globals.ts then I can easily extract it from there with TypeGuards.isInterfaceDeclaration, but that would mean I still need to leave inlining of lib.web_assembly.d.ts as is.

Do you have a better idea how to handle that without putting all the contents of lib.web_assembly.d.ts into globals.ts?

@kitsonk
Copy link
Contributor

kitsonk commented Mar 13, 2019

lib.web_assembly.d.ts is a different beast, though they are closely related... lib.web_assembly.d.ts are declarations that should be in TypeScript (see: microsoft/TypeScript#29747) and hopefully will one day, so all we are doing is replicating that.

In this case we are taking an already existing global interface and extending it.

Actually thinking about lib.web_assembly.d.ts, we should inline it in assets.ts and include it in the lib: [ "esnext", "web_assembly" ] in our configuration for the compiler.ts. We would then replace it with the official one when/if the issue gets resolved. (See: #1930)

@bartlomieju
Copy link
Member Author

All clear now 👍 thanks for explanation. I'll get to it after finishing this one.

@ry ry closed this as completed in #1920 Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants