vercel / turbo

Incremental bundler and build system optimized for JavaScript and TypeScript, written in Rust – including Turbopack and Turborepo.

Home Page:https://turbo.build

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript autoimport suggestion not working

igor-ribeiro opened this issue · comments

What version of Turborepo are you using?

1.0.15

Describe the Bug

Import suggestion from Typescript are not working, unless you have the packages with an empty import (import {} from 'ui')

turborepo-ts-import

Expected Behavior

Typescript should recognize the packages from the monorepo.

To Reproduce

  1. Start a new project with npx create-turbo@latest or clone an example (I cloned the design system)
  2. Open the index.tsx (or any file from the apps)
  3. Remove the import statement of one shared component
  4. Try to auto import it from IDE

I had this error using npm@6. upgrade my node to 16 and it worked

Yeah, I'm using nvim in an environment with node 16 and it doesn't show the error, but the import is still not working.

Updated the description to better explain the issue.

It works if I put ../../packages/**/*.tsx on web/tsconfig.json for example.
But then the import is import { Button } from "../../../packages/ui"; instead of import { Button } from 'ui';

Got it working... You need to add "references": [{ "path": "../../packages/PACKAGE_NAME" }] on tsconfig.json of every package that you want to use PACKAGE_NAME.

@igor-ribeiro could you show me an example of tsconfig.json for the package you want to use and the tsconfig.json for the package in which you want to import it? it's not working out of the box for me even after setting composite: true in the package i want to reference

@fabrixiop26 I'm using the examples from here, so it's the same tsconfig.json.

I can only get this working for actual code, not types.
Anyone find a solution for this?

image

image

wanting to bump this and see if anyone has figured this piece out!

@sghsri Can you try again with our updated examples? We believe that those should work for tsconfig sharing as well as types in VSCode.

Our recent example updates have fixed this!