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

Provide option to intercept module/file resolution #1497

Open
lo1tuma opened this issue Jan 29, 2024 · 0 comments
Open

Provide option to intercept module/file resolution #1497

lo1tuma opened this issue Jan 29, 2024 · 0 comments

Comments

@lo1tuma
Copy link
Contributor

lo1tuma commented Jan 29, 2024

I’m using ts-morph to build a dependency tree of js source files and d.ts files. I want both trees, that’s why I create two separate projects with different settings. For resolving the js tree I need to ignore all d.ts files. Ideally there would be an easy way to disable .d.ts file resolution, but unfortunately there is no such compiler option.
I’ve looked at the resolution host but it only allows to map some paths in a different way. I would need a way to filter them.

Right now I’ve found a solution, but it is quite cumbersome. I’ve used a custom file host which is an instance of RealFileSystemHost but overrides fileExists* and dirExists* methods so I can return false for .d.ts files or node_modules/@types imports. This works, but I think it is not a good solution, especially because RealFileSystemHost is not exported directly and I need to use @ts-morph/common.

Is there any better way to solve this? Maybe adding new methods to the resolution host would be a good approach to filter files and folders.

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

No branches or pull requests

1 participant