TypeScript/tests/baselines/reference/findAllRefsCommonJsRequire.baseline.jsonc
Nathan Shively-Sanders f0fe1b88ca
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
2021-09-22 13:43:52 -07:00

196 lines
3.6 KiB
Plaintext

// === /b.js ===
// const { [|f|] } = require('./a')
// /*FIND ALL REFS*/[|f|]
// === /a.js ===
// function [|f|]() { }
// export { [|f|] }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/b.js",
"kind": "alias",
"name": "(alias) function f(): void\nimport f",
"textSpan": {
"start": 8,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "alias",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "function",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "f",
"kind": "aliasName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": "import",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "f",
"kind": "aliasName"
}
],
"contextSpan": {
"start": 0,
"length": 28
}
},
"references": [
{
"textSpan": {
"start": 8,
"length": 1
},
"fileName": "/b.js",
"contextSpan": {
"start": 0,
"length": 28
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 29,
"length": 1
},
"fileName": "/b.js",
"isWriteAccess": false,
"isDefinition": false
}
]
},
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/a.js",
"kind": "function",
"name": "function f(): void",
"textSpan": {
"start": 9,
"length": 1
},
"displayParts": [
{
"text": "function",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "f",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 0,
"length": 16
}
},
"references": [
{
"textSpan": {
"start": 9,
"length": 1
},
"fileName": "/a.js",
"contextSpan": {
"start": 0,
"length": 16
},
"isWriteAccess": true,
"isDefinition": false
},
{
"textSpan": {
"start": 26,
"length": 1
},
"fileName": "/a.js",
"contextSpan": {
"start": 17,
"length": 12
},
"isWriteAccess": true,
"isDefinition": false
}
]
}
]