You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// a.tsexportinterfaceFoo{}declare global {namespacens{export{Foo}}}// b.tstypeFoo=ns.Foo;constbar=(foo?: Foo)=>{};
Declaration emit would use the parameter type Foo as written if the parameter weren’t optional, and if bar were written as a function declaration. When it’s optional, under strictNullChecks, it creates a new type identity unioned with undefined and prints that new type, so it doesn’t realize Foo is locally accessible, and it doesn’t randomly trawl global namespaces so it would never come up with ns.Foo, so instead it writes import("./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.
An existing workaround is to replace type with import. So declaration emit is looking to see if aliases are in scope, but not type aliases or other local declarations.
Allegedly, even without strictNullChecks, it still starts going through this route and doesn’t realize that we should just be able to print the type as written.
Activity
andrewbranch commentedon Mar 30, 2022
Update: this is false