Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/services/goToDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
getPropertySymbolsFromContextualType,
getTargetLabel,
getTextOfPropertyName,
getTokenAtPosition,
getTouchingPropertyName,
getTouchingToken,
hasEffectiveModifier,
Expand Down Expand Up @@ -449,7 +450,7 @@ function getFirstTypeArgumentDefinitions(typeChecker: TypeChecker, type: Type, n
/// Goto type
/** @internal */
export function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): readonly DefinitionInfo[] | undefined {
const node = getTouchingPropertyName(sourceFile, position);
const node = getTokenAtPosition(sourceFile, position);
if (node === sourceFile) {
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
// * @property {number} x
// |]*/
//
// /** @typedef {{ name: string }} Foo */
// /** @type {I} */
// const /*GOTO TYPE*/i = { x: 0 };
// const /*GOTO TYPE*/a = { x: 0 };
//
// const b = /** @type {Foo} */({});
// const c = /** @type {Foo} */({}).name;
// const d = /** @type {Foo} */({})['name'];

// === Details ===
[
Expand All @@ -19,4 +24,94 @@
"unverified": false,
"failedAliasResolution": false
}
]



// === goToType ===
// === /a.js ===
// /**
// * @typedef {object} I
// * @property {number} x
// */
//
// /** <|@typedef {{ name: string }} [|Foo|]|> */
// /** @type {I} */
// const a = { x: 0 };
//
// const b = /** @type {/*GOTO TYPE*/Foo} */({});
// const c = /** @type {Foo} */({}).name;
// const d = /** @type {Foo} */({})['name'];

// === Details ===
[
{
"kind": "type",
"name": "Foo",
"containerName": "",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]



// === goToType ===
// === /a.js ===
// /**
// * @typedef {object} I
// * @property {number} x
// */
//
// /** <|@typedef {{ name: string }} [|Foo|]|> */
// /** @type {I} */
// const a = { x: 0 };
//
// const b = /** @type {Foo} */({});
// const c = /** @type {/*GOTO TYPE*/Foo} */({}).name;
// const d = /** @type {Foo} */({})['name'];

// === Details ===
[
{
"kind": "type",
"name": "Foo",
"containerName": "",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]



// === goToType ===
// === /a.js ===
// /**
// * @typedef {object} I
// * @property {number} x
// */
//
// /** <|@typedef {{ name: string }} [|Foo|]|> */
// /** @type {I} */
// const a = { x: 0 };
//
// const b = /** @type {Foo} */({});
// const c = /** @type {Foo} */({}).name;
// const d = /** @type {/*GOTO TYPE*/Foo} */({})['name'];

// === Details ===
[
{
"kind": "type",
"name": "Foo",
"containerName": "",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,5 @@ Info seq [hh:mm:ss:mss] response:
"command": "typeDefinition",
"request_seq": 1,
"success": true,
"body": [
{
"file": "/tests/cases/fourslash/server/a.ts",
"start": {
"line": 1,
"offset": 14
},
"end": {
"line": 1,
"offset": 17
},
"contextStart": {
"line": 1,
"offset": 1
},
"contextEnd": {
"line": 1,
"offset": 20
}
}
]
"body": []
}
15 changes: 1 addition & 14 deletions tests/baselines/reference/typedefinition01.baseline.jsonc
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
// === goToType ===
// === /tests/cases/fourslash/server/a.ts ===
// export class [|Foo|] {}

// === /tests/cases/fourslash/server/b.ts ===
// import n = require('./a');
// var x/*GOTO TYPE*/ = new n.Foo();

// === Details ===
[
{
"containerKind": "",
"containerName": "",
"kind": "",
"name": ""
}
]
// var x/*GOTO TYPE*/ = new n.Foo();
10 changes: 8 additions & 2 deletions tests/cases/fourslash/goToTypeDefinition_typedef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
//// * @property {number} x
//// */
////
/////** @typedef {{ name: string }} Foo */

/////** @type {I} */
////const /*ref*/i = { x: 0 };
////const /*a*/a = { x: 0 };
////
////const b = /** @type {/*b*/Foo} */({});
////const c = /** @type {/*c*/Foo} */({}).name;
////const d = /** @type {/*d*/Foo} */({})['name'];

verify.baselineGoToType("ref");
verify.baselineGoToType("a", "b", "c", "d");