mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Make isDefinition aware of declaring symbol (#45920)
* Make isDefinition aware of target symbol
Initial code, haven't fixed any tests yet.
* Update baselines
This commit includes a regression for commonjs aliases:
```js
// @filename: a.js
function f() { }
module.exports.f = f
// @filename: b.js
const { f } = require('./a')
f/**/
```
Now says that `f` in b.js has 1 reference --
the alias `module.exports.f = f`. This is not correct (or not exactly
correct), but correctly fixing will involve re-creating the ad-hoc
commonjs alias resolution code from the checker. I don't think it's
worth it for an edge case like this.
* update more unit tests
* Fix symbol lookup for constructors
* More baselines + two fixes
1. Fix `default` support.
2. Add a secondary declaration location for commonjs assignment
declarations.
* Update rest of baselines
* Switch a few more tests over to baselines
This commit is contained in:
@@ -32,7 +32,8 @@ ${exportNestedObject}
|
||||
const referenceMainTs = (mainTs: File, text: string): protocol.ReferencesResponseItem =>
|
||||
makeReferenceItem({
|
||||
file: mainTs,
|
||||
isDefinition: true,
|
||||
isDefinition: false,
|
||||
isWriteAccess: true,
|
||||
lineText: mainTs.content,
|
||||
contextText: mainTs.content,
|
||||
text,
|
||||
@@ -113,8 +114,11 @@ ${exportNestedObject}
|
||||
referenceMainTs(mainTs, "valueC"),
|
||||
referenceModTs(
|
||||
{ text: "valueC", lineText: exportObjectDestructured, contextText: "valueC: 0" },
|
||||
{ options: { index: 1 } },
|
||||
),
|
||||
{
|
||||
options: { index: 1 },
|
||||
isDefinition: false,
|
||||
isWriteAccess: true,
|
||||
}),
|
||||
],
|
||||
symbolDisplayString: "const valueC: number",
|
||||
symbolName: "valueC",
|
||||
@@ -171,7 +175,11 @@ ${exportNestedObject}
|
||||
lineText: exportNestedObject,
|
||||
contextText: "valueF: 1",
|
||||
},
|
||||
{ options: { index: 1 } },
|
||||
{
|
||||
options: { index: 1 },
|
||||
isDefinition: false,
|
||||
isWriteAccess: true,
|
||||
},
|
||||
),
|
||||
],
|
||||
symbolDisplayString: "const valueF: number",
|
||||
|
||||
@@ -186,7 +186,8 @@ function foo() {
|
||||
file: keyboardTestTs,
|
||||
text: searchStr,
|
||||
contextText: importStr,
|
||||
isDefinition: true,
|
||||
isDefinition: false,
|
||||
isWriteAccess: true,
|
||||
lineText: importStr
|
||||
}),
|
||||
makeReferenceItem({
|
||||
@@ -200,7 +201,8 @@ function foo() {
|
||||
file: terminalTs,
|
||||
text: searchStr,
|
||||
contextText: importStr,
|
||||
isDefinition: true,
|
||||
isDefinition: false,
|
||||
isWriteAccess: true,
|
||||
lineText: importStr
|
||||
}),
|
||||
makeReferenceItem({
|
||||
|
||||
Reference in New Issue
Block a user