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

Intellisense does not pickup Typescript 3 references #26913

Closed
mjbvz opened this issue Sep 5, 2018 · 19 comments
Closed

Intellisense does not pickup Typescript 3 references #26913

mjbvz opened this issue Sep 5, 2018 · 19 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Sep 5, 2018

From @tommedema on August 27, 2018 3:12

  • VSCode Version: 1.26.1
  • OS Version: OSX High Sierra

Steps to Reproduce:

  1. git clone [email protected]:tommedema/serverless-mono-example.git
  2. cd serverless-mono-example && yarn install && code .
  3. if you change a typing in package random, it is not picked up by intellisense in typescript packages that reference to it in the same workspace (e.g. sls-random); you'd have to compile first

for example, change fetchRandomNumber in random to return a Promise<string>, and sls-random still expects a Promise<number>

Note that sls-random is connected with random through Typescript 3 references:

{
  "extends": "../../tsconfig.settings.json",
  "compilerOptions": {
    "outDir": "dist",
    "rootDir": "src"
  },
  "references": [
    { "path": "../random" }
  ]
}

And therefore intellisense should pickup the referenced typings dynamically.

Does this issue occur when all extensions are disabled?: Yes

Copied from original issue: microsoft/vscode#57242

@mjbvz mjbvz self-assigned this Sep 5, 2018
@mjbvz mjbvz removed their assignment Sep 5, 2018
@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Sep 5, 2018
@ajafff
Copy link
Contributor

ajafff commented Sep 5, 2018

From the TypeScript Handbook: https://www.typescriptlang.org/docs/handbook/project-references.html

Because dependent projects make use of .d.ts files that are built from their dependencies, you’ll either have to check in certain build outputs or build a project after cloning it before you can navigate the project in an editor without seeing spurious errors. We’re working on a behind-the-scenes .d.ts generation process that should be able to mitigate this, but for now we recommend informing developers that they should build after cloning.

@donaldpipowitch
Copy link
Contributor

I have a similar problem. Is this a duplicate or is my example different? https://github.com/donaldpipowitch/typescript-refactoring-references

@chriswoodle
Copy link

Getting the same issue, have to compile a project for its type intellisense in other projects to update when changes are made.

It's a big problem for a repo I'm working on that has 19 different package references. When running the tsc watch, it can take over 15 sec for a typing to update.

@MLoughry
Copy link

MLoughry commented Dec 5, 2018

Running into the same issue in our mono-repo.

This is labeled as VS Code Tracked, but the linked bug in their repo is closed. @mjbvz, is this something that needs to be fixed in Typescript or VS Code?

@chriswoodle
Copy link

Correct me if I’m wrong, but since vscode relys on TSServer for providing information for intellesence, and the new References feature uses the output .d.ts for each project for typing; the TSServer would have to have a way to bypass the .d.ts files and directly go to the source to determine typings. I would think that this is a TS issue and not only VSCode.

@tommedema
Copy link

Anything I can do to help this get fixed?

@chriswoodle
Copy link

@mjbvz Any updates? Or a pointer to progress on the behind-the-scenes .d.ts generation process @ajafff? Thanks.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature and removed VS Code Tracked There is a VS Code equivalent to this issue labels Mar 7, 2019
@domoritz
Copy link

I would like to bump this issue. We are running into this problem in our monorepo and it's making development more difficult in particular for newcomers.

@wmira
Copy link

wmira commented May 1, 2019

I have a sample project that uses project reference. You need to set properly baseUrl to the top level output and this should enable type checks to work

https://github.com/wmira/react-ts-starter/tree/master/project-reference

@chriswoodle
Copy link

I have a sample project that uses project reference. You need to set properly baseUrl to the top level output and this should enable type checks to work

https://github.com/wmira/react-ts-starter/tree/master/project-reference

@wmira That's the current workaround, at least what my team uses. Ideally vscode would understand types as you change them without the watch running or having to run tsc build (which I believe is the issue outlined by mjvbz).

@domoritz
Copy link

domoritz commented May 1, 2019

@wmira I'm confused about your setup. Why are these properties directories that do not exist? Also, this still means that you have to compile the typscript to get references to work. As I understand the issue, this is the main problem, not that references do not work at all.

@wmira
Copy link

wmira commented May 1, 2019 via email

@domoritz
Copy link

domoritz commented May 1, 2019

I see. But I still have to compile (and re-compile) to get working jump-to-reference in VSCode across project boundaries. Unfortunately, that's a huge UX problem.

@sunniejai
Copy link

sunniejai commented Aug 13, 2019

@wmira i just gave your sample a try. However, if you delete import { greet } from 'module1/util' in App.tsx, you'll notice that vscode can't figure out to auto import greet, back into the file.

It seems that once you include that line, that vscode can find all the symbols within module1/util fine, but before that it can't pick it up. Likewise, if you add a new file, say module/util2 and export a function hello(), vscode won't be able to find that until you've referenced it in at least one file.

Is that something that you were able to overcome with a workaround?

@gurdiga
Copy link

gurdiga commented Jan 22, 2020

Just poking to ask if there is any progress on this. 🤓

I see it’s labeled as Awaiting More Feedback and I’m wondering what kind of feedback would help here? 🤔

@adryanf
Copy link

adryanf commented Feb 10, 2020

I definitely think this fix is high priority. I my case (yarn workspaces with nohoist and typescript modules) I haven't been able to find a good workaround.

@sheetalkamat
Copy link
Member

The initial issue is fixed by #32028.

@sheetalkamat sheetalkamat added the Fixed A PR has been merged for this issue label Feb 10, 2020
@rhyek
Copy link

rhyek commented Nov 5, 2020

I'm not quite sure what the proposed fix actually is. Ended up using pnpm as package manger and its workspaces which helps resolve this issue pretty easily as it symlinks referenced projects to the importing application's node_modules folder.

@agcty
Copy link

agcty commented Dec 28, 2022

Is this fixed? Seems like it isn't and this is the current behaviour:

@wmira i just gave your sample a try. However, if you delete import { greet } from 'module1/util' in App.tsx, you'll notice that vscode can't figure out to auto import greet, back into the file.

It seems that once you include that line, that vscode can find all the symbols within module1/util fine, but before that it can't pick it up. Likewise, if you add a new file, say module/util2 and export a function hello(), vscode won't be able to find that until you've referenced it in at least one file.

Is that something that you were able to overcome with a workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Fixed A PR has been merged for this issue Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests