mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
fix: change deprecated FunctionLike type to SignatureDeclaration (#40795)
This commit is contained in:
parent
1e49ad8370
commit
0c7d45a9ed
@ -2124,7 +2124,7 @@ namespace ts {
|
||||
return isTypeQueryNode(location) || ((
|
||||
isFunctionLikeDeclaration(location) ||
|
||||
(location.kind === SyntaxKind.PropertyDeclaration && !hasSyntacticModifier(location, ModifierFlags.Static))
|
||||
) && (!lastLocation || lastLocation !== (location as FunctionLike | PropertyDeclaration).name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred
|
||||
) && (!lastLocation || lastLocation !== (location as SignatureDeclaration | PropertyDeclaration).name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred
|
||||
}
|
||||
if (lastLocation && lastLocation === (location as FunctionExpression | ArrowFunction).name) {
|
||||
return false;
|
||||
|
||||
@ -14,8 +14,8 @@ namespace ts {
|
||||
export function isInternalDeclaration(node: Node, currentSourceFile: SourceFile) {
|
||||
const parseTreeNode = getParseTreeNode(node);
|
||||
if (parseTreeNode && parseTreeNode.kind === SyntaxKind.Parameter) {
|
||||
const paramIdx = (parseTreeNode.parent as FunctionLike).parameters.indexOf(parseTreeNode as ParameterDeclaration);
|
||||
const previousSibling = paramIdx > 0 ? (parseTreeNode.parent as FunctionLike).parameters[paramIdx - 1] : undefined;
|
||||
const paramIdx = (parseTreeNode.parent as SignatureDeclaration).parameters.indexOf(parseTreeNode as ParameterDeclaration);
|
||||
const previousSibling = paramIdx > 0 ? (parseTreeNode.parent as SignatureDeclaration).parameters[paramIdx - 1] : undefined;
|
||||
const text = currentSourceFile.text;
|
||||
const commentRanges = previousSibling
|
||||
? concatenate(
|
||||
|
||||
@ -4508,7 +4508,7 @@ namespace ts {
|
||||
isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean;
|
||||
isLateBound(node: Declaration): node is LateBoundDeclaration;
|
||||
collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined;
|
||||
isImplementationOfOverload(node: FunctionLike): boolean | undefined;
|
||||
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
|
||||
isRequiredInitializedParameter(node: ParameterDeclaration): boolean;
|
||||
isOptionalUninitializedParameterProperty(node: ParameterDeclaration): boolean;
|
||||
isExpandoFunctionDeclaration(node: FunctionDeclaration): boolean;
|
||||
|
||||
@ -222,7 +222,7 @@ namespace ts.codefix {
|
||||
importAdder: ImportAdder,
|
||||
sourceFile: SourceFile,
|
||||
parameterDeclaration: ParameterDeclaration,
|
||||
containingFunction: FunctionLike,
|
||||
containingFunction: SignatureDeclaration,
|
||||
program: Program,
|
||||
host: LanguageServiceHost,
|
||||
cancellationToken: CancellationToken,
|
||||
@ -268,7 +268,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function annotateJSDocThis(changes: textChanges.ChangeTracker, sourceFile: SourceFile, containingFunction: FunctionLike, typeNode: TypeNode) {
|
||||
function annotateJSDocThis(changes: textChanges.ChangeTracker, sourceFile: SourceFile, containingFunction: SignatureDeclaration, typeNode: TypeNode) {
|
||||
addJSDocTags(changes, sourceFile, containingFunction, [
|
||||
factory.createJSDocThisTag(/*tagName*/ undefined, factory.createJSDocTypeExpression(typeNode)),
|
||||
]);
|
||||
@ -409,7 +409,7 @@ namespace ts.codefix {
|
||||
}));
|
||||
}
|
||||
|
||||
function getFunctionReferences(containingFunction: FunctionLike, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): readonly Identifier[] | undefined {
|
||||
function getFunctionReferences(containingFunction: SignatureDeclaration, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): readonly Identifier[] | undefined {
|
||||
let searchToken;
|
||||
switch (containingFunction.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
@ -534,7 +534,7 @@ namespace ts.codefix {
|
||||
return combineTypes(inferTypesFromReferencesSingle(references));
|
||||
}
|
||||
|
||||
function parameters(declaration: FunctionLike): ParameterInference[] | undefined {
|
||||
function parameters(declaration: SignatureDeclaration): ParameterInference[] | undefined {
|
||||
if (references.length === 0 || !declaration.parameters) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ namespace ts.OutliningElementsCollector {
|
||||
}
|
||||
}
|
||||
|
||||
function functionSpan(node: FunctionLike, body: Block, sourceFile: SourceFile): OutliningSpan | undefined {
|
||||
function functionSpan(node: SignatureDeclaration, body: Block, sourceFile: SourceFile): OutliningSpan | undefined {
|
||||
const openToken = tryGetFunctionOpenToken(node, body, sourceFile);
|
||||
const closeToken = findChildOfKind(body, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== SyntaxKind.ArrowFunction);
|
||||
@ -303,7 +303,7 @@ namespace ts.OutliningElementsCollector {
|
||||
return { textSpan, kind, hintSpan, bannerText, autoCollapse };
|
||||
}
|
||||
|
||||
function tryGetFunctionOpenToken(node: FunctionLike, body: Block, sourceFile: SourceFile): Node | undefined {
|
||||
function tryGetFunctionOpenToken(node: SignatureDeclaration, body: Block, sourceFile: SourceFile): Node | undefined {
|
||||
if (isNodeArrayMultiLine(node.parameters, sourceFile)) {
|
||||
const openParenToken = findChildOfKind(node, SyntaxKind.OpenParenToken, sourceFile);
|
||||
if (openParenToken) {
|
||||
|
||||
@ -236,7 +236,7 @@ namespace ts.SymbolDisplay {
|
||||
else if ((isNameOfFunctionDeclaration(location) && !(symbolFlags & SymbolFlags.Accessor)) || // name of function declaration
|
||||
(location.kind === SyntaxKind.ConstructorKeyword && location.parent.kind === SyntaxKind.Constructor)) { // At constructor keyword of constructor declaration
|
||||
// get the signature from the declaration and write it
|
||||
const functionDeclaration = <FunctionLike>location.parent;
|
||||
const functionDeclaration = <SignatureDeclaration>location.parent;
|
||||
// Use function declaration to write the signatures only if the symbol corresponding to this declaration
|
||||
const locationIsSymbolDeclaration = symbol.declarations && find(symbol.declarations, declaration =>
|
||||
declaration === (location.kind === SyntaxKind.ConstructorKeyword ? functionDeclaration.parent : functionDeclaration));
|
||||
|
||||
@ -254,7 +254,7 @@ namespace ts.textChanges {
|
||||
|
||||
export type ThisTypeAnnotatable = FunctionDeclaration | FunctionExpression;
|
||||
|
||||
export function isThisTypeAnnotatable(containingFunction: FunctionLike): containingFunction is ThisTypeAnnotatable {
|
||||
export function isThisTypeAnnotatable(containingFunction: SignatureDeclaration): containingFunction is ThisTypeAnnotatable {
|
||||
return isFunctionExpression(containingFunction) || isFunctionDeclaration(containingFunction);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user