mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
fix(53138): go-to-definition not working on expression of SatisfiesExpression (#53164)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
parent
df3bec6674
commit
458c5e6c64
@ -221,7 +221,7 @@ export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile
|
||||
if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
||||
const definitions = shorthandSymbol?.declarations ? shorthandSymbol.declarations.map(decl => createDefinitionInfo(decl, typeChecker, shorthandSymbol, node, /*unverified*/ false, failedAliasResolution)) : emptyArray;
|
||||
return concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || emptyArray);
|
||||
return concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node));
|
||||
}
|
||||
|
||||
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
|
||||
@ -245,7 +245,8 @@ export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile
|
||||
});
|
||||
}
|
||||
|
||||
return concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
|
||||
const objectLiteralElementDefinition = getDefinitionFromObjectLiteralElement(typeChecker, node);
|
||||
return concatenate(fileReferenceDefinition, objectLiteralElementDefinition.length ? objectLiteralElementDefinition : getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,6 +279,7 @@ function getDefinitionFromObjectLiteralElement(typeChecker: TypeChecker, node: N
|
||||
getDefinitionFromSymbol(typeChecker, propertySymbol, node));
|
||||
}
|
||||
}
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
function getDefinitionFromOverriddenMember(typeChecker: TypeChecker, node: Node) {
|
||||
@ -366,7 +368,7 @@ export function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile
|
||||
const typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
|
||||
return typeDefinitions.length ? typeDefinitions
|
||||
: !(symbol.flags & SymbolFlags.Value) && symbol.flags & SymbolFlags.Type ? getDefinitionFromSymbol(typeChecker, skipAlias(symbol, typeChecker), node, failedAliasResolution)
|
||||
: undefined;
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function definitionFromType(type: Type, checker: TypeChecker, node: Node, failedAliasResolution: boolean | undefined): readonly DefinitionInfo[] {
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
// === goToDefinition ===
|
||||
// === /tests/cases/fourslash/goToDefinitionSatisfiesExpression1.ts ===
|
||||
// const STRINGS = {
|
||||
// /*GOTO DEF*/<|[|{| textSpan: true |}title|]: 'A Title'|>,
|
||||
// } satisfies Record<string,string>;
|
||||
//
|
||||
// //somewhere in app
|
||||
// STRINGS.title
|
||||
|
||||
// === Details ===
|
||||
[
|
||||
{
|
||||
"kind": "property",
|
||||
"name": "title",
|
||||
"containerName": "__object",
|
||||
"isLocal": false,
|
||||
"isAmbient": false,
|
||||
"unverified": false,
|
||||
"failedAliasResolution": false
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
|
||||
// === goToDefinition ===
|
||||
// === /tests/cases/fourslash/goToDefinitionSatisfiesExpression1.ts ===
|
||||
// const STRINGS = {
|
||||
// <|[|title|]: 'A Title'|>,
|
||||
// } satisfies Record<string,string>;
|
||||
//
|
||||
// //somewhere in app
|
||||
// STRINGS./*GOTO DEF*/title
|
||||
|
||||
// === Details ===
|
||||
[
|
||||
{
|
||||
"kind": "property",
|
||||
"name": "title",
|
||||
"containerName": "__object",
|
||||
"isLocal": false,
|
||||
"isAmbient": false,
|
||||
"unverified": false,
|
||||
"failedAliasResolution": false
|
||||
}
|
||||
]
|
||||
10
tests/cases/fourslash/goToDefinitionSatisfiesExpression1.ts
Normal file
10
tests/cases/fourslash/goToDefinitionSatisfiesExpression1.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/// <reference path="./fourslash.ts"/>
|
||||
|
||||
////const STRINGS = {
|
||||
//// [|/*definition*/title|]: 'A Title',
|
||||
////} satisfies Record<string,string>;
|
||||
////
|
||||
//////somewhere in app
|
||||
////STRINGS.[|/*usage*/title|]
|
||||
|
||||
verify.baselineGoToDefinition("definition", "usage")
|
||||
Loading…
x
Reference in New Issue
Block a user