mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'main' into getTypeAtLocation-support-class-expr
This commit is contained in:
@@ -171,13 +171,15 @@ namespace ts.GoToDefinition {
|
||||
if (!baseDeclaration) return;
|
||||
|
||||
const baseTypeNode = getEffectiveBaseTypeNode(baseDeclaration);
|
||||
const baseType = baseTypeNode ? typeChecker.getTypeAtLocation(baseTypeNode) : undefined;
|
||||
if (!baseType) return;
|
||||
if (!baseTypeNode) return;
|
||||
const expression = skipParentheses(baseTypeNode.expression);
|
||||
const base = isClassExpression(expression) ? expression.symbol : typeChecker.getSymbolAtLocation(expression);
|
||||
if (!base) return;
|
||||
|
||||
const name = unescapeLeadingUnderscores(getTextOfPropertyName(classElement.name));
|
||||
const symbol = hasStaticModifier(classElement)
|
||||
? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbolAtLocation(baseType.symbol, baseDeclaration), name)
|
||||
: typeChecker.getPropertyOfType(baseType, name);
|
||||
? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbol(base), name)
|
||||
: typeChecker.getPropertyOfType(typeChecker.getDeclaredTypeOfSymbol(base), name);
|
||||
if (!symbol) return;
|
||||
|
||||
return getDefinitionFromSymbol(typeChecker, symbol, node);
|
||||
|
||||
@@ -790,6 +790,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getContextualTypeFromParentOrAncestorTypeNode(node: Expression, checker: TypeChecker): Type | undefined {
|
||||
if (node.flags & (NodeFlags.JSDoc & ~NodeFlags.JavaScriptFile)) return undefined;
|
||||
|
||||
const contextualType = getContextualTypeFromParent(node, checker);
|
||||
if (contextualType) return contextualType;
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// === /a.ts ===
|
||||
// interface Foo {
|
||||
// property: /*FIND ALL REFS*/"[|foo|]";
|
||||
// }
|
||||
// /**
|
||||
// * @type {{ property: "foo"}}
|
||||
// */
|
||||
// const obj: Foo = {
|
||||
// property: "[|foo|]",
|
||||
// }
|
||||
|
||||
[
|
||||
{
|
||||
"definition": {
|
||||
"containerKind": "",
|
||||
"containerName": "",
|
||||
"fileName": "/a.ts",
|
||||
"kind": "var",
|
||||
"name": "foo",
|
||||
"textSpan": {
|
||||
"start": 31,
|
||||
"length": 3
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "\"foo\"",
|
||||
"kind": "stringLiteral"
|
||||
}
|
||||
]
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"textSpan": {
|
||||
"start": 31,
|
||||
"length": 3
|
||||
},
|
||||
"fileName": "/a.ts",
|
||||
"isWriteAccess": false,
|
||||
"isInString": true
|
||||
},
|
||||
{
|
||||
"textSpan": {
|
||||
"start": 111,
|
||||
"length": 3
|
||||
},
|
||||
"fileName": "/a.ts",
|
||||
"isWriteAccess": false,
|
||||
"isInString": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,11 @@
|
||||
/*====== /a.ts ======*/
|
||||
|
||||
interface Foo {
|
||||
property: "RENAME";
|
||||
}
|
||||
/**
|
||||
* @type {{ property: "foo"}}
|
||||
*/
|
||||
const obj: Foo = {
|
||||
property: "RENAME",
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @filename: /a.ts
|
||||
////interface Foo {
|
||||
//// property: /**/"foo";
|
||||
////}
|
||||
/////**
|
||||
//// * @type {{ property: "foo"}}
|
||||
//// */
|
||||
////const obj: Foo = {
|
||||
//// property: "foo",
|
||||
////}
|
||||
|
||||
verify.baselineFindAllReferences("");
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
// @Filename: goToDefinitionOverrideJsdoc.ts
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
|
||||
//// export class C extends CompletelyUndefined {
|
||||
//// /**
|
||||
//// * @override/*1*/
|
||||
//// * @returns {{}}
|
||||
//// */
|
||||
//// static foo() {
|
||||
//// return {}
|
||||
//// }
|
||||
//// }
|
||||
|
||||
verify.goToDefinition(['1'], [])
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @filename: /a.ts
|
||||
////interface Foo {
|
||||
//// property: /**/"foo";
|
||||
////}
|
||||
/////**
|
||||
//// * @type {{ property: "foo"}}
|
||||
//// */
|
||||
////const obj: Foo = {
|
||||
//// property: "foo",
|
||||
////}
|
||||
|
||||
verify.baselineRename("", {});
|
||||
Reference in New Issue
Block a user