turbo icon indicating copy to clipboard operation
turbo copied to clipboard

Typescript autoimport suggestion not working

Open igor-ribeiro opened this issue 3 years ago • 10 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

igor-ribeiro avatar Dec 16 '21 22:12 igor-ribeiro

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

MarcARoberge avatar Dec 16 '21 23:12 MarcARoberge

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.

igor-ribeiro avatar Dec 16 '21 23:12 igor-ribeiro

Updated the description to better explain the issue.

igor-ribeiro avatar Dec 16 '21 23:12 igor-ribeiro

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';

igor-ribeiro avatar Dec 16 '21 23:12 igor-ribeiro

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 avatar Dec 17 '21 00:12 igor-ribeiro

@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 avatar Dec 19 '21 17:12 fabrixiop26

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

igor-ribeiro avatar Dec 19 '21 23:12 igor-ribeiro

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

image

image

sghsri avatar Jan 23 '22 14:01 sghsri

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

sghsri avatar Sep 17 '22 02:09 sghsri

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

nathanhammond avatar Sep 19 '22 15:09 nathanhammond

Our recent example updates have fixed this!

anthonyshew avatar Dec 05 '23 06:12 anthonyshew