Declaration emit adds unnecessary import types #47849
Labels
Bug
A bug in TypeScript
Domain: Declaration Emit
The issue relates to the emission of d.ts files
Fix Available
A PR has been opened for this issue
Milestone
Two low-hanging fruits for improvement:
Foo
as written if the parameter weren’t optional, and ifbar
were written as a function declaration. When it’s optional, understrictNullChecks
, it creates a new type identity unioned withundefined
and prints that new type, so it doesn’t realizeFoo
is locally accessible, and it doesn’t randomly trawl global namespaces so it would never come up withns.Foo
, so instead it writesimport("./a").Foo
.Allegedly, even withoutstrictNullChecks
, it still starts going through this route and doesn’t realize that we should just be able to print the type as written.type
withimport
. So declaration emit is looking to see if aliases are in scope, but not type aliases or other local declarations.The text was updated successfully, but these errors were encountered: