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

Automatic Closure Externs from TypeScript #289

Open
kristoferbaxter opened this issue Jan 18, 2020 · 0 comments
Open

Automatic Closure Externs from TypeScript #289

kristoferbaxter opened this issue Jan 18, 2020 · 0 comments

Comments

@kristoferbaxter
Copy link
Contributor

kristoferbaxter commented Jan 18, 2020

This is a thoughtpad, not an issue but there isn't a better place to file it.

Let's support TypeScript as a mechanism to generate Closure Types

There are two sources of code for a TypeScript project. Local source, and remote (including NPM depdencies).

For Local Source: Convert TypeScript types into Closure annotations. Similar to Tsickle.

For Remote Source: Find the appropriate definition file (either @types/x or local to the remote source) and convert the resource to a closure extern definition. This extern must only be given to closure compiler for source that imports this remote source.

How

  1. During rollup's transform step, we can indicate this plugin requires to inspect source before other plugins. If the input to rollup was typescript (uses the .ts or .tsx extension) then we can transform the local source using this tsickle-alike (or even just tsickle with configuration).

  2. Before we execute the conversion, we should rename each imported name with a uuid unique to the import path. This will allow us to know during chunk transformation which imported members come from where (and use the appropriate externs when compiling them).

  3. Once we have chunks, use the modified import names to map back to original imported names and know which externs to use on this chunk during compilation.

Should this be done for simple optimizations?

We could for simple optimization just enhance the existing system by obtaining the proper shape for each imported member during the transform phase (still using the rename trick with uuids per imported path).

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

1 participant