TypeScript/tests/baselines/reference/findAllRefsIsDefinition.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

945 lines
20 KiB
Plaintext

// === /tests/cases/fourslash/findAllRefsIsDefinition.ts ===
// declare function [|foo|](a: number): number;
// declare function [|foo|](a: string): string;
// declare function [|foo|]/*FIND ALL REFS*/(a: string | number): string | number;
//
// function foon(a: number): number;
// function foon(a: string): string;
// function foon(a: string | number): string | number {
// return a
// }
//
// [|foo|]; foon;
//
// export const bar = 123;
// console.log({ bar });
//
// interface IFoo {
// foo(): void;
// }
// class Foo implements IFoo {
// constructor(n: number)
// constructor()
// constructor(n: number?) { }
// foo(): void { }
// static init() { return new this() }
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"kind": "function",
"name": "function foo(a: number): number (+2 overloads)",
"textSpan": {
"start": 17,
"length": 3
},
"displayParts": [
{
"text": "function",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "foo",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": "a",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": "+",
"kind": "operator"
},
{
"text": "2",
"kind": "numericLiteral"
},
{
"text": " ",
"kind": "space"
},
{
"text": "overloads",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
}
],
"contextSpan": {
"start": 0,
"length": 40
}
},
"references": [
{
"textSpan": {
"start": 17,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 0,
"length": 40
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 58,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 41,
"length": 40
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 99,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 82,
"length": 58
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 279,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/findAllRefsIsDefinition.ts ===
// declare function foo(a: number): number;
// declare function foo(a: string): string;
// declare function foo(a: string | number): string | number;
//
// function [|foon|](a: number): number;
// function [|foon|](a: string): string;
// function [|foon|]/*FIND ALL REFS*/(a: string | number): string | number {
// return a
// }
//
// foo; [|foon|];
//
// export const bar = 123;
// console.log({ bar });
//
// interface IFoo {
// foo(): void;
// }
// class Foo implements IFoo {
// constructor(n: number)
// constructor()
// constructor(n: number?) { }
// foo(): void { }
// static init() { return new this() }
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"kind": "function",
"name": "function foon(a: number): number (+1 overload)",
"textSpan": {
"start": 151,
"length": 4
},
"displayParts": [
{
"text": "function",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "foon",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": "a",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": "+",
"kind": "operator"
},
{
"text": "1",
"kind": "numericLiteral"
},
{
"text": " ",
"kind": "space"
},
{
"text": "overload",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
}
],
"contextSpan": {
"start": 142,
"length": 33
}
},
"references": [
{
"textSpan": {
"start": 151,
"length": 4
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 142,
"length": 33
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 185,
"length": 4
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 176,
"length": 33
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 219,
"length": 4
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 210,
"length": 67
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 284,
"length": 4
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/findAllRefsIsDefinition.ts ===
// declare function foo(a: number): number;
// declare function foo(a: string): string;
// declare function foo(a: string | number): string | number;
//
// function foon(a: number): number;
// function foon(a: string): string;
// function foon(a: string | number): string | number {
// return a
// }
//
// foo; foon;
//
// export const [|bar|]/*FIND ALL REFS*/ = 123;
// console.log({ [|bar|] });
//
// interface IFoo {
// foo(): void;
// }
// class Foo implements IFoo {
// constructor(n: number)
// constructor()
// constructor(n: number?) { }
// foo(): void { }
// static init() { return new this() }
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"kind": "const",
"name": "const bar: 123",
"textSpan": {
"start": 304,
"length": 3
},
"displayParts": [
{
"text": "const",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "bar",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "123",
"kind": "stringLiteral"
}
],
"contextSpan": {
"start": 291,
"length": 23
}
},
"references": [
{
"textSpan": {
"start": 304,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 291,
"length": 23
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 329,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"isWriteAccess": true,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/findAllRefsIsDefinition.ts ===
// declare function foo(a: number): number;
// declare function foo(a: string): string;
// declare function foo(a: string | number): string | number;
//
// function foon(a: number): number;
// function foon(a: string): string;
// function foon(a: string | number): string | number {
// return a
// }
//
// foo; foon;
//
// export const bar = 123;
// console.log({ bar });
//
// interface IFoo {
// [|foo|]/*FIND ALL REFS*/(): void;
// }
// class Foo implements IFoo {
// constructor(n: number)
// constructor()
// constructor(n: number?) { }
// [|foo|](): void { }
// static init() { return new this() }
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"kind": "method",
"name": "(method) IFoo.foo(): void",
"textSpan": {
"start": 359,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "IFoo",
"kind": "interfaceName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 359,
"length": 12
}
},
"references": [
{
"textSpan": {
"start": 359,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 359,
"length": 12
},
"isWriteAccess": false,
"isDefinition": true
}
]
},
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"kind": "method",
"name": "(method) Foo.foo(): void",
"textSpan": {
"start": 483,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Foo",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 483,
"length": 15
}
},
"references": [
{
"textSpan": {
"start": 483,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 483,
"length": 15
},
"isWriteAccess": true,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/findAllRefsIsDefinition.ts ===
// declare function foo(a: number): number;
// declare function foo(a: string): string;
// declare function foo(a: string | number): string | number;
//
// function foon(a: number): number;
// function foon(a: string): string;
// function foon(a: string | number): string | number {
// return a
// }
//
// foo; foon;
//
// export const bar = 123;
// console.log({ bar });
//
// interface IFoo {
// foo(): void;
// }
// class Foo implements IFoo {
// [|constructor|](n: number)
// [|constructor|]()
// /*FIND ALL REFS*/[|constructor|](n: number?) { }
// foo(): void { }
// static init() { return new [|this|]() }
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"kind": "class",
"name": "class Foo",
"textSpan": {
"start": 380,
"length": 3
},
"displayParts": [
{
"text": "class",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Foo",
"kind": "className"
}
],
"contextSpan": {
"start": 374,
"length": 166
}
},
"references": [
{
"textSpan": {
"start": 406,
"length": 11
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 406,
"length": 22
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 433,
"length": 11
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 433,
"length": 13
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 451,
"length": 11
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 451,
"length": 27
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 530,
"length": 4
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/findAllRefsIsDefinition.ts ===
// declare function foo(a: number): number;
// declare function foo(a: string): string;
// declare function foo(a: string | number): string | number;
//
// function foon(a: number): number;
// function foon(a: string): string;
// function foon(a: string | number): string | number {
// return a
// }
//
// foo; foon;
//
// export const bar = 123;
// console.log({ bar });
//
// interface IFoo {
// [|foo|](): void;
// }
// class Foo implements IFoo {
// constructor(n: number)
// constructor()
// constructor(n: number?) { }
// [|foo|]/*FIND ALL REFS*/(): void { }
// static init() { return new this() }
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"kind": "method",
"name": "(method) IFoo.foo(): void",
"textSpan": {
"start": 359,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "IFoo",
"kind": "interfaceName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 359,
"length": 12
}
},
"references": [
{
"textSpan": {
"start": 359,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 359,
"length": 12
},
"isWriteAccess": false,
"isDefinition": false
}
]
},
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"kind": "method",
"name": "(method) Foo.foo(): void",
"textSpan": {
"start": 483,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Foo",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 483,
"length": 15
}
},
"references": [
{
"textSpan": {
"start": 483,
"length": 3
},
"fileName": "/tests/cases/fourslash/findAllRefsIsDefinition.ts",
"contextSpan": {
"start": 483,
"length": 15
},
"isWriteAccess": true,
"isDefinition": true
}
]
}
]