f0fe1b88ca
* 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
577 lines
11 KiB
Plaintext
577 lines
11 KiB
Plaintext
// === /tests/cases/fourslash/a.ts ===
|
|
// import { [|A|] as A1 } from "./f";
|
|
// const a1 = new [|A1|]("a1");
|
|
// export default class extends A1 { }
|
|
// export { [|B|] as [|B1|] } from "./f";
|
|
|
|
// === /tests/cases/fourslash/f.ts ===
|
|
// class A {
|
|
// /*FIND ALL REFS*/[|constructor|](s: string) {}
|
|
// }
|
|
// class B extends A { }
|
|
// export { [|A|], [|B|] };
|
|
|
|
// === /tests/cases/fourslash/b.ts ===
|
|
// import B, { B1 } from "./a";
|
|
// const d = new [|B|]("b");
|
|
// const d1 = new [|B1|]("b1");
|
|
|
|
[
|
|
{
|
|
"definition": {
|
|
"containerKind": "",
|
|
"containerName": "",
|
|
"fileName": "/tests/cases/fourslash/f.ts",
|
|
"kind": "class",
|
|
"name": "class A",
|
|
"textSpan": {
|
|
"start": 6,
|
|
"length": 1
|
|
},
|
|
"displayParts": [
|
|
{
|
|
"text": "class",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "A",
|
|
"kind": "className"
|
|
}
|
|
],
|
|
"contextSpan": {
|
|
"start": 0,
|
|
"length": 41
|
|
}
|
|
},
|
|
"references": [
|
|
{
|
|
"textSpan": {
|
|
"start": 14,
|
|
"length": 11
|
|
},
|
|
"fileName": "/tests/cases/fourslash/f.ts",
|
|
"contextSpan": {
|
|
"start": 14,
|
|
"length": 25
|
|
},
|
|
"isWriteAccess": false,
|
|
"isDefinition": true
|
|
},
|
|
{
|
|
"textSpan": {
|
|
"start": 73,
|
|
"length": 1
|
|
},
|
|
"fileName": "/tests/cases/fourslash/f.ts",
|
|
"contextSpan": {
|
|
"start": 64,
|
|
"length": 16
|
|
},
|
|
"isWriteAccess": true,
|
|
"isDefinition": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"definition": {
|
|
"containerKind": "",
|
|
"containerName": "",
|
|
"fileName": "/tests/cases/fourslash/f.ts",
|
|
"kind": "class",
|
|
"name": "class B",
|
|
"textSpan": {
|
|
"start": 48,
|
|
"length": 1
|
|
},
|
|
"displayParts": [
|
|
{
|
|
"text": "class",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "B",
|
|
"kind": "className"
|
|
}
|
|
],
|
|
"contextSpan": {
|
|
"start": 42,
|
|
"length": 21
|
|
}
|
|
},
|
|
"references": [
|
|
{
|
|
"textSpan": {
|
|
"start": 76,
|
|
"length": 1
|
|
},
|
|
"fileName": "/tests/cases/fourslash/f.ts",
|
|
"contextSpan": {
|
|
"start": 64,
|
|
"length": 16
|
|
},
|
|
"isWriteAccess": true,
|
|
"isDefinition": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"definition": {
|
|
"containerKind": "",
|
|
"containerName": "",
|
|
"fileName": "/tests/cases/fourslash/f.ts",
|
|
"kind": "alias",
|
|
"name": "(alias) class B\nexport B",
|
|
"textSpan": {
|
|
"start": 76,
|
|
"length": 1
|
|
},
|
|
"displayParts": [
|
|
{
|
|
"text": "(",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": "alias",
|
|
"kind": "text"
|
|
},
|
|
{
|
|
"text": ")",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "class",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "B",
|
|
"kind": "aliasName"
|
|
},
|
|
{
|
|
"text": "\n",
|
|
"kind": "lineBreak"
|
|
},
|
|
{
|
|
"text": "export",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "B",
|
|
"kind": "aliasName"
|
|
}
|
|
],
|
|
"contextSpan": {
|
|
"start": 64,
|
|
"length": 16
|
|
}
|
|
},
|
|
"references": [
|
|
{
|
|
"textSpan": {
|
|
"start": 101,
|
|
"length": 1
|
|
},
|
|
"fileName": "/tests/cases/fourslash/a.ts",
|
|
"contextSpan": {
|
|
"start": 92,
|
|
"length": 30
|
|
},
|
|
"isWriteAccess": false,
|
|
"isDefinition": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"definition": {
|
|
"containerKind": "",
|
|
"containerName": "",
|
|
"fileName": "/tests/cases/fourslash/a.ts",
|
|
"kind": "alias",
|
|
"name": "(alias) class B1\nexport B1",
|
|
"textSpan": {
|
|
"start": 106,
|
|
"length": 2
|
|
},
|
|
"displayParts": [
|
|
{
|
|
"text": "(",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": "alias",
|
|
"kind": "text"
|
|
},
|
|
{
|
|
"text": ")",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "class",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "B1",
|
|
"kind": "aliasName"
|
|
},
|
|
{
|
|
"text": "\n",
|
|
"kind": "lineBreak"
|
|
},
|
|
{
|
|
"text": "export",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "B1",
|
|
"kind": "aliasName"
|
|
}
|
|
],
|
|
"contextSpan": {
|
|
"start": 92,
|
|
"length": 30
|
|
}
|
|
},
|
|
"references": [
|
|
{
|
|
"textSpan": {
|
|
"start": 106,
|
|
"length": 2
|
|
},
|
|
"fileName": "/tests/cases/fourslash/a.ts",
|
|
"contextSpan": {
|
|
"start": 92,
|
|
"length": 30
|
|
},
|
|
"isWriteAccess": true,
|
|
"isDefinition": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"definition": {
|
|
"containerKind": "",
|
|
"containerName": "",
|
|
"fileName": "/tests/cases/fourslash/b.ts",
|
|
"kind": "alias",
|
|
"name": "(alias) class B1\nimport B1",
|
|
"textSpan": {
|
|
"start": 12,
|
|
"length": 2
|
|
},
|
|
"displayParts": [
|
|
{
|
|
"text": "(",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": "alias",
|
|
"kind": "text"
|
|
},
|
|
{
|
|
"text": ")",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "class",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "B1",
|
|
"kind": "aliasName"
|
|
},
|
|
{
|
|
"text": "\n",
|
|
"kind": "lineBreak"
|
|
},
|
|
{
|
|
"text": "import",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "B1",
|
|
"kind": "aliasName"
|
|
}
|
|
],
|
|
"contextSpan": {
|
|
"start": 0,
|
|
"length": 28
|
|
}
|
|
},
|
|
"references": [
|
|
{
|
|
"textSpan": {
|
|
"start": 66,
|
|
"length": 2
|
|
},
|
|
"fileName": "/tests/cases/fourslash/b.ts",
|
|
"isWriteAccess": false,
|
|
"isDefinition": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"definition": {
|
|
"containerKind": "",
|
|
"containerName": "",
|
|
"fileName": "/tests/cases/fourslash/f.ts",
|
|
"kind": "alias",
|
|
"name": "(alias) class A\nexport A",
|
|
"textSpan": {
|
|
"start": 73,
|
|
"length": 1
|
|
},
|
|
"displayParts": [
|
|
{
|
|
"text": "(",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": "alias",
|
|
"kind": "text"
|
|
},
|
|
{
|
|
"text": ")",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "class",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "A",
|
|
"kind": "aliasName"
|
|
},
|
|
{
|
|
"text": "\n",
|
|
"kind": "lineBreak"
|
|
},
|
|
{
|
|
"text": "export",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "A",
|
|
"kind": "aliasName"
|
|
}
|
|
],
|
|
"contextSpan": {
|
|
"start": 64,
|
|
"length": 16
|
|
}
|
|
},
|
|
"references": [
|
|
{
|
|
"textSpan": {
|
|
"start": 9,
|
|
"length": 1
|
|
},
|
|
"fileName": "/tests/cases/fourslash/a.ts",
|
|
"contextSpan": {
|
|
"start": 0,
|
|
"length": 30
|
|
},
|
|
"isWriteAccess": false,
|
|
"isDefinition": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"definition": {
|
|
"containerKind": "",
|
|
"containerName": "",
|
|
"fileName": "/tests/cases/fourslash/a.ts",
|
|
"kind": "alias",
|
|
"name": "(alias) class A1\nimport A1",
|
|
"textSpan": {
|
|
"start": 14,
|
|
"length": 2
|
|
},
|
|
"displayParts": [
|
|
{
|
|
"text": "(",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": "alias",
|
|
"kind": "text"
|
|
},
|
|
{
|
|
"text": ")",
|
|
"kind": "punctuation"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "class",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "A1",
|
|
"kind": "aliasName"
|
|
},
|
|
{
|
|
"text": "\n",
|
|
"kind": "lineBreak"
|
|
},
|
|
{
|
|
"text": "import",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "A1",
|
|
"kind": "aliasName"
|
|
}
|
|
],
|
|
"contextSpan": {
|
|
"start": 0,
|
|
"length": 30
|
|
}
|
|
},
|
|
"references": [
|
|
{
|
|
"textSpan": {
|
|
"start": 46,
|
|
"length": 2
|
|
},
|
|
"fileName": "/tests/cases/fourslash/a.ts",
|
|
"isWriteAccess": false,
|
|
"isDefinition": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"definition": {
|
|
"containerKind": "",
|
|
"containerName": "",
|
|
"fileName": "/tests/cases/fourslash/a.ts",
|
|
"kind": "class",
|
|
"name": "class default",
|
|
"textSpan": {
|
|
"start": 56,
|
|
"length": 35
|
|
},
|
|
"displayParts": [
|
|
{
|
|
"text": "class",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "default",
|
|
"kind": "className"
|
|
}
|
|
]
|
|
},
|
|
"references": []
|
|
},
|
|
{
|
|
"definition": {
|
|
"containerKind": "",
|
|
"containerName": "",
|
|
"fileName": "/tests/cases/fourslash/b.ts",
|
|
"kind": "alias",
|
|
"name": "import B",
|
|
"textSpan": {
|
|
"start": 7,
|
|
"length": 1
|
|
},
|
|
"displayParts": [
|
|
{
|
|
"text": "import",
|
|
"kind": "keyword"
|
|
},
|
|
{
|
|
"text": " ",
|
|
"kind": "space"
|
|
},
|
|
{
|
|
"text": "B",
|
|
"kind": "aliasName"
|
|
}
|
|
],
|
|
"contextSpan": {
|
|
"start": 0,
|
|
"length": 28
|
|
}
|
|
},
|
|
"references": [
|
|
{
|
|
"textSpan": {
|
|
"start": 43,
|
|
"length": 1
|
|
},
|
|
"fileName": "/tests/cases/fourslash/b.ts",
|
|
"isWriteAccess": false,
|
|
"isDefinition": false
|
|
}
|
|
]
|
|
}
|
|
] |