pgtyped icon indicating copy to clipboard operation
pgtyped copied to clipboard

Avoid depending on antlr4ts types in @pgtyped/query

Open danvk opened this issue 2 years ago • 1 comments

When I add a dependency on @pgtyped/query, it pulls in antlr4ts as a transitive dependency. It has to do this since antlr4ts is a runtime dependency of @pgtyped/query.

But because antlr4ts bundles its TypeScript types and @pgtyped/query uses TypeScript's auto-generated .d.ts files, it winds up pulling in all the antlr4ts .d.ts files, too. When I run tsc --listFiles on my project, I see that tsc visits ~100 antlr4ts files:

$ tsc --noEmit --listFiles | grep 'antlr4ts' /tmp/tsc-files-master.txt | wc -l
111

So far as I'm aware, none of the antlr4ts types appear in the public API of @pgtyped/query, so I don't think they should get pulled in by the .d.ts files distributed with the @pgtyped/query npm module.

I have no idea how to implement this (using the auto-generated .d.ts files is quite convenient) but it seems like a reasonable goal, so here's the issue!

danvk avatar Jun 13 '22 21:06 danvk

Hm, not sure how to solve this. The closest thing I found to achieving this is this issue. Does including the ANTLR type defs have any measurable impact on compilation speed?

adelsz avatar Jun 15 '22 21:06 adelsz