Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dummdidumm opened this issue Mar 6, 2025 · 2 comments Β· May be fixed by #61379
Open

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

dummdidumm opened this issue Mar 6, 2025 · 2 comments Β· May be fixed by #61379

Comments

@dummdidumm
Copy link

dummdidumm commented Mar 6, 2025

πŸ”Ž 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.

@Andarist
Copy link
Contributor

Andarist commented Mar 6, 2025

You can do multi-file repros in the bug workbench. See here. From the given information it isn't entirely obvious to me where do you request references and which ones are missing.

@dummdidumm
Copy link
Author

TIL! I adjusted the link and description, hope it's clear now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants