microsoft/TypeScript

"Go to definition" not working with `declarationMap` and projects references

OliverJAsh opened this issue · 11 comments

TypeScript Version: 3.0.0-rc

Search Terms:

Code

Full reproduction case

src
├── client
│   ├── main.ts
│   └── tsconfig.json
└── shared
    ├── main.ts
    └── tsconfig.json
// src/client/main.ts
import { foo } from '../shared/main';

console.log({ foo })
// src/client/tsconfig.json
{
    "compilerOptions": {
        // Needed for project references.
        "composite": true,
        "declaration": true,

        // Other options...
        "outDir": "../../lib/client",
        "strict": true, "module": "esnext", "moduleResolution": "node",
    },
    "references": [
        { "path": "../shared" }
    ]
}
// src/shared/main.ts
export const foo = 1;
// src/shared/tsconfig.json
{
    "compilerOptions": {
        // Needed for project references.
        "composite": true,
        "declaration": true,
        "declarationMap": true,

        // Other options...
        "outDir": "../../lib/shared",
        "strict": true, "module": "esnext", "moduleResolution": "node",
    }
}
  • Run tsc --build ./src/client/
  • Configure VSCode TypeScript version to use workspace, and reload VSCode

Expected behavior:
"Go to definition" should work for foo identifier in src/client/main.ts.

Actual behavior:
"Go to definition" does not work for foo identifier in src/client/main.ts.

image

Having looked at the other issue, I think this is a dupe of #25792 - or rather, #25792 is a dupe of this, but I looked into #25792 first. 😛 In any case, I should have a fix promptly.

@weswigham I just tested this with 3.0.1 and I can still reproduce. Any ideas? Can we re-open?

@weswigham can you take a look.

On 3.0.1, have this issue, too.

Code checks, compiles, runs, etc. just "Go to definition" not working.

Can we re-open this issue whilst it is investigated again?

I just tried declarationMap option in TypeScript 3.0.1. But it doesn't work both in VS 2017 15.8.0 Preview 5.0/VS Code 1.26.0

https://github.com/Soul-Master/typescript3-composite-project/tree/declarationMap

In VS Code 1.26.0

image

image

In VS 2017 15.8.0 Preview 5.0

image

image

@weswigham This is not fixed. Just tested with TS 3.0.3.

Full repro: https://github.com/OliverJAsh/typescript-3-client-server-shared

Please can we re-open this issue? /cc @weswigham @mhegazy

(Sorry to pester here but I think this needs attention, as it's a very basic use case.)

Is there any way to help figuring this out. I have declarationMap working in a small toy project that I created to learn about how to setup a monorepo with project references.

However, in our actual project repo when I use "Go To Definition" I get sent to the FILENAME.d.ts file of the referenced project. Even though I have a FILENAME.d.ts.map right next to it.

I tried setting TypeScript > TsServer:Log to verbose. And then tail the log file when I go to the definition. But nothing interesting shows up in the log file. I can't figure out if TS thought it wasn't supposed to look for a map file, if it looked but couldn't find, or if it found something but it wasn't valid.

@OliverJAsh your repro seems to be fixed in the latest versions of TS (I'm pretty sure we've had a continuous stream of improvements to this area since 3.0).

Just tested, it works! Thanks 🎉