Skip to content

References from dynamic imports not recognized when indirectly exporting variableΒ #61366

Open
@dummdidumm

Description

@dummdidumm

πŸ”Ž Search Terms

references dynamic import

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about references

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?ts=5.8.2#code/PTAEAEDMEsBsFMB2BDAtvAXKAJvGjoAXaAe0QDpCBnAWAChIBXRAY2LNAA0AKASlADeAX3qEAngAd4XUAF5QhAE6N4AbnrwAHhJKLCOPMkax9nVaBA4SoAET5soRXnhPW8KjdAALF-Hr+6Syg4JDRMUEYqZABzeEpaOmhUHT0ZSEUSVFAAcnJgXHwiUkRs9Tp6MwswQi9oKkdnVxZpOtBIEmZsAOQqMVY25jZi0B7sPkF6AEgWMip9ZDkRgHdkIlAklMJuXPy8aAJ2Et4yyeRyAqMTc0sa1rIW+sQSQinkFbWN3S2dgv2ismyvEoPkQ3G4qH4sgAfKBUOdDMZ9MAAFQKWr1e7rR7PUDI4DHUD0ER0IA

πŸ’» Code

// @filename: definition.ts
function X() {}
type X = true;
export default X; // do "find references" here


// @filename: usage.ts
import X from './definition';

X; // this reference is found

async function asd() {
	const a = await import('./definition');
	a.default; // this one is not
	await import('./definition').then((m) => m.default /* this one is not */); 
}

πŸ™ Actual behavior

This needs the files to be copied into your IDE to reproduce. In VS Code, do "find references" on export default X. You'll see that the references of the indirect export (e.g. function x()...; export default x instead of export default function x()...) are not recognized for dynamic imports (for static imports they are).

πŸ™‚ Expected behavior

Recognize references for dynamic imports, too

Additional information about the issue

The playground needs to be copied into real files locally, as the playground isn't multifile-capable (from what I know), but it's needed for this reproduction.

Doing indirect exports is sometimes necessary in order to do declaration merging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions