TypeScript: Intellisense does not pickup Typescript 3 references

From @tommedema on August 27, 2018 3:12

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

Steps to Reproduce:

  1. git clone git@github.com: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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 33
  • Comments: 19 (3 by maintainers)

Most upvoted comments

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.

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.

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? 🤔

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).

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?

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.

@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.

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

Anything I can do to help this get fixed?

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.

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