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

Typescript autoimport suggestions not working with exports wildcard #6844

Closed
1 task done
BarakChamo opened this issue Dec 21, 2023 · 2 comments
Closed
1 task done
Labels
wontfix This will not be worked on

Comments

@BarakChamo
Copy link

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

npx create-turbo@canary

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

turbo@1.11.2

Describe the Bug

When using wildcards in a monorepo's package.json exports field, which is supported by typescript and compiled properly, there are no typescript autoimport suggestions inside VS Code.

Similar issues have been covered here: #331
And some of the constraints have been addressed by TypeScript here: microsoft/TypeScript#53116 (comment)

I'm opening this issue because I think this is a key dev experience improvement, since for suggestions to work right now every component and export to be explicitly declared in the package.json, which feels like an anti-pattern and yet another point of friction for fast-paced repositories.

As referenced in the TypeScript issue, I believe "internal packages" are not yet supported since they export .ts files and not compiled .js and type defs, but perhaps the wise heads here will be able to offer a solution.

Expected Behavior

Since wildcard exports in package.json is working fine in turbo repos both locally and both in deployment, with both compilation and typing, it should also work during development with autoimports and suggestions in the IDE.

To Reproduce

This issue is very simple to reproduce:

  1. Create a monorepo with npx create-turbo@latest
  2. Overwrite the packages/ui to a wildcard exports:
  "exports": {
    "./*": "./src/*.tsx"
  },

Try to add a Card or Code component in web/app/page.tsx and suggestions will no longer work in the editor.

Additional context

As mentioned, as far as I understand this is not a feature that is supported by TypeScript at the moment, but I'm not too familiar with tsconfig configurations for different types of projects, and usually rely on boilerplate scaffolding.

Would appreciate any advice on how to achieve the desired dev flexibility with current limitations of the tooling.

@BarakChamo BarakChamo added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage owned-by: turborepo labels Dec 21, 2023
@anthonyshew anthonyshew added wontfix This will not be worked on and removed kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage labels Dec 21, 2023
@anthonyshew
Copy link
Contributor

This is working as intended. As you've mentioned, this isn't supported by TypeScript. I can't seem to find it right now but there is an issue in the TypeScript repo describing how wildcards aren't supported for auto-imports due to performance reasons.

As a proof point, this is the exports strategy that we use in the Vercel monorepo and we don't find it to be an anti-pattern nor a point of friction. Of course, the wildcard would indeed be more convenient but, like you said, this is outside of Turbo's ability to solve.

@anthonyshew
Copy link
Contributor

Found the issue while looking for something else: microsoft/TypeScript#53116 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants