Skip unnecessary instatiation of anonymous types#7448
Conversation
| const declaration = <DeclarationWithTypeParameters>node; | ||
| if (declaration.typeParameters) { | ||
| for (const d of declaration.typeParameters) { | ||
| if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(d.symbol))) { |
There was a problem hiding this comment.
why does it work to say d.symbol directly when normally you have to say getSymbolOfNode(node)? (for example, in the thisType case below).
There was a problem hiding this comment.
We know that type parameters are never subject to global symbol merging, so getSymbolOfNode(d) will always be the same as d.symbol. We do the same thing in a few other places in the compiler.
|
The fix looks good to me. If you can think of a way to show that the fix really skips unneeded instantiations without needing a giant test to trigger out-of-memory, by all means do. (Maybe the symbols file? I don't much about its information.) Otherwise just grabbing the altered bluebird d.ts from my PR will work. |
|
Latest commit pulls over tests from #7138. |
Skip unnecessary instatiation of anonymous types
Fixes #7097.
This PR is basically a revised implementation of #7138. It corrects #7138 by only optimizing in cases where the anonymous type to be instantiated isn't itself an instantiation. Also, the implementation of type mappers and type erasers is reworked to share more code.
@sandersn Let's discuss how to merge this with #7138. Perhaps we just pull the tests over to this PR.