Skip to content

Commit 0c7d45a

Browse files
authored
fix: change deprecated FunctionLike type to SignatureDeclaration (#40795)
1 parent 1e49ad8 commit 0c7d45a

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,7 @@ namespace ts {
21242124
return isTypeQueryNode(location) || ((
21252125
isFunctionLikeDeclaration(location) ||
21262126
(location.kind === SyntaxKind.PropertyDeclaration && !hasSyntacticModifier(location, ModifierFlags.Static))
2127-
) && (!lastLocation || lastLocation !== (location as FunctionLike | PropertyDeclaration).name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred
2127+
) && (!lastLocation || lastLocation !== (location as SignatureDeclaration | PropertyDeclaration).name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred
21282128
}
21292129
if (lastLocation && lastLocation === (location as FunctionExpression | ArrowFunction).name) {
21302130
return false;

src/compiler/transformers/declarations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace ts {
1414
export function isInternalDeclaration(node: Node, currentSourceFile: SourceFile) {
1515
const parseTreeNode = getParseTreeNode(node);
1616
if (parseTreeNode && parseTreeNode.kind === SyntaxKind.Parameter) {
17-
const paramIdx = (parseTreeNode.parent as FunctionLike).parameters.indexOf(parseTreeNode as ParameterDeclaration);
18-
const previousSibling = paramIdx > 0 ? (parseTreeNode.parent as FunctionLike).parameters[paramIdx - 1] : undefined;
17+
const paramIdx = (parseTreeNode.parent as SignatureDeclaration).parameters.indexOf(parseTreeNode as ParameterDeclaration);
18+
const previousSibling = paramIdx > 0 ? (parseTreeNode.parent as SignatureDeclaration).parameters[paramIdx - 1] : undefined;
1919
const text = currentSourceFile.text;
2020
const commentRanges = previousSibling
2121
? concatenate(

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4508,7 +4508,7 @@ namespace ts {
45084508
isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean;
45094509
isLateBound(node: Declaration): node is LateBoundDeclaration;
45104510
collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined;
4511-
isImplementationOfOverload(node: FunctionLike): boolean | undefined;
4511+
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
45124512
isRequiredInitializedParameter(node: ParameterDeclaration): boolean;
45134513
isOptionalUninitializedParameterProperty(node: ParameterDeclaration): boolean;
45144514
isExpandoFunctionDeclaration(node: FunctionDeclaration): boolean;

src/services/codefixes/inferFromUsage.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ namespace ts.codefix {
222222
importAdder: ImportAdder,
223223
sourceFile: SourceFile,
224224
parameterDeclaration: ParameterDeclaration,
225-
containingFunction: FunctionLike,
225+
containingFunction: SignatureDeclaration,
226226
program: Program,
227227
host: LanguageServiceHost,
228228
cancellationToken: CancellationToken,
@@ -268,7 +268,7 @@ namespace ts.codefix {
268268
}
269269
}
270270

271-
function annotateJSDocThis(changes: textChanges.ChangeTracker, sourceFile: SourceFile, containingFunction: FunctionLike, typeNode: TypeNode) {
271+
function annotateJSDocThis(changes: textChanges.ChangeTracker, sourceFile: SourceFile, containingFunction: SignatureDeclaration, typeNode: TypeNode) {
272272
addJSDocTags(changes, sourceFile, containingFunction, [
273273
factory.createJSDocThisTag(/*tagName*/ undefined, factory.createJSDocTypeExpression(typeNode)),
274274
]);
@@ -409,7 +409,7 @@ namespace ts.codefix {
409409
}));
410410
}
411411

412-
function getFunctionReferences(containingFunction: FunctionLike, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): readonly Identifier[] | undefined {
412+
function getFunctionReferences(containingFunction: SignatureDeclaration, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): readonly Identifier[] | undefined {
413413
let searchToken;
414414
switch (containingFunction.kind) {
415415
case SyntaxKind.Constructor:
@@ -534,7 +534,7 @@ namespace ts.codefix {
534534
return combineTypes(inferTypesFromReferencesSingle(references));
535535
}
536536

537-
function parameters(declaration: FunctionLike): ParameterInference[] | undefined {
537+
function parameters(declaration: SignatureDeclaration): ParameterInference[] | undefined {
538538
if (references.length === 0 || !declaration.parameters) {
539539
return undefined;
540540
}

src/services/outliningElementsCollector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ namespace ts.OutliningElementsCollector {
288288
}
289289
}
290290

291-
function functionSpan(node: FunctionLike, body: Block, sourceFile: SourceFile): OutliningSpan | undefined {
291+
function functionSpan(node: SignatureDeclaration, body: Block, sourceFile: SourceFile): OutliningSpan | undefined {
292292
const openToken = tryGetFunctionOpenToken(node, body, sourceFile);
293293
const closeToken = findChildOfKind(body, SyntaxKind.CloseBraceToken, sourceFile);
294294
return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== SyntaxKind.ArrowFunction);
@@ -303,7 +303,7 @@ namespace ts.OutliningElementsCollector {
303303
return { textSpan, kind, hintSpan, bannerText, autoCollapse };
304304
}
305305

306-
function tryGetFunctionOpenToken(node: FunctionLike, body: Block, sourceFile: SourceFile): Node | undefined {
306+
function tryGetFunctionOpenToken(node: SignatureDeclaration, body: Block, sourceFile: SourceFile): Node | undefined {
307307
if (isNodeArrayMultiLine(node.parameters, sourceFile)) {
308308
const openParenToken = findChildOfKind(node, SyntaxKind.OpenParenToken, sourceFile);
309309
if (openParenToken) {

src/services/symbolDisplay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ namespace ts.SymbolDisplay {
236236
else if ((isNameOfFunctionDeclaration(location) && !(symbolFlags & SymbolFlags.Accessor)) || // name of function declaration
237237
(location.kind === SyntaxKind.ConstructorKeyword && location.parent.kind === SyntaxKind.Constructor)) { // At constructor keyword of constructor declaration
238238
// get the signature from the declaration and write it
239-
const functionDeclaration = <FunctionLike>location.parent;
239+
const functionDeclaration = <SignatureDeclaration>location.parent;
240240
// Use function declaration to write the signatures only if the symbol corresponding to this declaration
241241
const locationIsSymbolDeclaration = symbol.declarations && find(symbol.declarations, declaration =>
242242
declaration === (location.kind === SyntaxKind.ConstructorKeyword ? functionDeclaration.parent : functionDeclaration));

src/services/textChanges.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ namespace ts.textChanges {
254254

255255
export type ThisTypeAnnotatable = FunctionDeclaration | FunctionExpression;
256256

257-
export function isThisTypeAnnotatable(containingFunction: FunctionLike): containingFunction is ThisTypeAnnotatable {
257+
export function isThisTypeAnnotatable(containingFunction: SignatureDeclaration): containingFunction is ThisTypeAnnotatable {
258258
return isFunctionExpression(containingFunction) || isFunctionDeclaration(containingFunction);
259259
}
260260

0 commit comments

Comments
 (0)