Different 'find all references' results on export default depending on trigger position
Bug Report
🔎 Search Terms
- find all references
- f12
- default export
🕗 Version & Regression Information
4.7-beta
Not a regression
💻 Code
For the code:
// index.ts
import bla from './index'
export default 123;
🙁 Actual behavior
- Run
find all referencesonexport. Notice no results returned
[Trace - 19:25:55.949] <semantic> Sending request: references (831). Response expected: yes. Current queue length: 0
Arguments: {
"file": "/Users/matb/projects/san/index.ts",
"line": 4,
"offset": 2
}
[Trace - 19:25:55.952] <semantic> Response received: references (831). Request took 3 ms. Success: true
Result: {
"refs": [],
"symbolName": "export",
"symbolStartOffset": 1,
"symbolDisplayString": "(property) default: 123"
}
- Now Run
find all referencesondefault. Notice the two correct references are returned
[Trace - 19:26:16.509] <semantic> Sending request: references (837). Response expected: yes. Current queue length: 0
Arguments: {
"file": "/Users/matb/projects/san/index.ts",
"line": 4,
"offset": 11
}
[Trace - 19:26:16.511] <semantic> Response received: references (837). Request took 2 ms. Success: true
Result: {
"refs": [
{
"file": "/Users/matb/projects/san/index.ts",
"start": {
"line": 4,
"offset": 8
},
"end": {
"line": 4,
"offset": 15
},
"contextStart": {
"line": 4,
"offset": 1
},
"contextEnd": {
"line": 4,
"offset": 20
},
"lineText": "export default 123; ",
"isWriteAccess": true,
"isDefinition": true
},
{
"file": "/Users/matb/projects/san/index.ts",
"start": {
"line": 2,
"offset": 8
},
"end": {
"line": 2,
"offset": 11
},
"contextStart": {
"line": 2,
"offset": 1
},
"contextEnd": {
"line": 2,
"offset": 26
},
"lineText": "import bla from './index'",
"isWriteAccess": true,
"isDefinition": false
}
],
"symbolName": "default",
"symbolStartOffset": 8,
"symbolDisplayString": "(property) default: 123"
}
🙂 Expected behavior
I think both cases should return the same references
unsure if this is the same issue, however I work for a company with a large mono-repo containing many TS projects. one of our leaf projects contains a Button export with over 16k+ references across the repo. the configuration for this leaf project is below (various properties omitted for privacy reasons):
{
"rootNames": [
...
],
"options": {
"plugins": [
...
],
"paths": {
...
},
"pathsBasePath": "<omitted>/web",
"composite": true,
"declaration": true,
"baseUrl": "<omitted>/web/src",
"experimentalDecorators": true,
"importHelpers": true,
"noImplicitOverride": true,
"isolatedModules": true,
"jsx": 4,
"lib": [
"lib.dom.d.ts",
"lib.dom.iterable.d.ts",
"lib.es2018.d.ts",
"lib.es2019.array.d.ts",
"lib.es2019.object.d.ts",
"lib.es2019.string.d.ts",
"lib.es2020.promise.d.ts",
"lib.es2020.string.d.ts",
"lib.es2020.intl.d.ts",
"lib.es2021.promise.d.ts",
"lib.es2022.string.d.ts",
"lib.es2022.array.d.ts",
"lib.es2022.error.d.ts"
],
"moduleResolution": 2,
"rootDir": "<omitted>",
"outDir": "<omitted>",
"strict": true,
"skipLibCheck": true,
"target": 6,
"sourceMap": true,
"inlineSources": true,
"module": 99,
"types": [],
"configFilePath": "<omitted>/tsconfig.json"
},
"projectReferences": [
...
]
}
Bug: When I attempt to run "Find All References" across the Button symbol it returns no results outside of the project.
// web/src/ui/base/button/button.ts
export { Button, ... } from './private/button';
Expected behaviour: tsserver to attempt a reverse dependency lookup of the Button symbol.
tsserver logs with version details:
Info 0 [16:21:54.777] Starting TS Server
Info 1 [16:21:54.777] Version: 5.8.2
Info 2 [16:21:54.777] Arguments: /usr/bin/node <omitted>/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName <omitted>/tscancellation-830202ca701f8d894b9f.tmp* --logVerbosity normal --logFile <omitted>/tsserver.log --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation
Info 3 [16:21:54.777] Platform: linux NodeVersion: v20.18.3 CaseSensitive: true
Info 4 [16:21:54.777] ServerMode: undefined hasUnknownServerMode: undefined
Info 5 [16:21:54.782] currentDirectory:: <omitted> useCaseSensitiveFileNames:: true
Info 6 [16:21:54.782] libs Location:: <omitted>/node_modules/.pnpm/[email protected]/node_modules/typescript/lib
Info 7 [16:21:54.782] globalTypingsCacheLocation:: <omitted>/.cache/typescript/5.8
Info 8 [16:21:54.793] Host information vscode
Info 9 [16:21:54.796] getConfigFileNameForFile:: File: <omitted> ProjectRootPath: <omitted>:: Result: <omitted>
Info 10 [16:21:54.797] Creating ConfiguredProject: <omitted>, currentDirectory: <omitted>
I've chased the problem down to here: https://github.com/microsoft/TypeScript/blob/beb69e4cdd61b1a0fd9ae21ae58bd4bd409d7217/src/server/editorServices.ts#L4769-L4770
Our solution level tsconfig.json contains the following config:
{
"files": [],
"include": [],
"references": [
{ "path": "..." },
{ "path": "..." },
...
]
}
however, the call to project.getCurrentProgram()?.getResolvedProjectReferences() returns undefined which, in turn, is because the program for our solution tsconfig project has NOT been initialized. is this a regression or has this always been a bug in tsserver?