fix: change deprecated FunctionLike type to SignatureDeclaration (#40795)

This commit is contained in:
Alex T
2020-10-06 17:51:01 +03:00
committed by GitHub
parent 1e49ad8370
commit 0c7d45a9ed
7 changed files with 12 additions and 12 deletions

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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));

View File

@@ -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);
}