mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
FunctionLike = SignatureDeclaration (#22365)
This commit is contained in:
@@ -14110,7 +14110,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getContainingObjectLiteral(func: FunctionLike): ObjectLiteralExpression | undefined {
|
||||
function getContainingObjectLiteral(func: SignatureDeclaration): ObjectLiteralExpression | undefined {
|
||||
return (func.kind === SyntaxKind.MethodDeclaration ||
|
||||
func.kind === SyntaxKind.GetAccessor ||
|
||||
func.kind === SyntaxKind.SetAccessor) && func.parent.kind === SyntaxKind.ObjectLiteralExpression ? func.parent :
|
||||
@@ -14128,7 +14128,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getContextualThisParameterType(func: FunctionLike): Type {
|
||||
function getContextualThisParameterType(func: SignatureDeclaration): Type {
|
||||
if (func.kind === SyntaxKind.ArrowFunction) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -14325,7 +14325,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function getContextualReturnType(functionDecl: FunctionLike): Type {
|
||||
function getContextualReturnType(functionDecl: SignatureDeclaration): Type {
|
||||
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
|
||||
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
||||
if (functionDecl.kind === SyntaxKind.Constructor ||
|
||||
@@ -20680,12 +20680,12 @@ namespace ts {
|
||||
let hasOverloads = false;
|
||||
let bodyDeclaration: FunctionLikeDeclaration;
|
||||
let lastSeenNonAmbientDeclaration: FunctionLikeDeclaration;
|
||||
let previousDeclaration: FunctionLike;
|
||||
let previousDeclaration: SignatureDeclaration;
|
||||
|
||||
const declarations = symbol.declarations;
|
||||
const isConstructor = (symbol.flags & SymbolFlags.Constructor) !== 0;
|
||||
|
||||
function reportImplementationExpectedError(node: FunctionLike): void {
|
||||
function reportImplementationExpectedError(node: SignatureDeclaration): void {
|
||||
if (node.name && nodeIsMissing(node.name)) {
|
||||
return;
|
||||
}
|
||||
@@ -20747,7 +20747,7 @@ namespace ts {
|
||||
let duplicateFunctionDeclaration = false;
|
||||
let multipleConstructorImplementation = false;
|
||||
for (const current of declarations) {
|
||||
const node = <FunctionLike>current;
|
||||
const node = <SignatureDeclaration>current;
|
||||
const inAmbientContext = node.flags & NodeFlags.Ambient;
|
||||
const inAmbientContextOrInterface = node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral || inAmbientContext;
|
||||
if (inAmbientContextOrInterface) {
|
||||
@@ -22755,12 +22755,12 @@ namespace ts {
|
||||
// TODO: Check that target label is valid
|
||||
}
|
||||
|
||||
function isGetAccessorWithAnnotatedSetAccessor(node: FunctionLike) {
|
||||
function isGetAccessorWithAnnotatedSetAccessor(node: SignatureDeclaration) {
|
||||
return node.kind === SyntaxKind.GetAccessor
|
||||
&& getEffectiveSetAccessorTypeAnnotationNode(getDeclarationOfKind<SetAccessorDeclaration>(node.symbol, SyntaxKind.SetAccessor)) !== undefined;
|
||||
}
|
||||
|
||||
function isUnwrappedReturnTypeVoidOrAny(func: FunctionLike, returnType: Type): boolean {
|
||||
function isUnwrappedReturnTypeVoidOrAny(func: SignatureDeclaration, returnType: Type): boolean {
|
||||
const unwrappedReturnType = (getFunctionFlags(func) & FunctionFlags.AsyncGenerator) === FunctionFlags.Async
|
||||
? getPromisedTypeOfPromise(returnType) // Async function
|
||||
: returnType; // AsyncGenerator function, Generator function, or normal function
|
||||
@@ -25481,7 +25481,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isImplementationOfOverload(node: FunctionLike) {
|
||||
function isImplementationOfOverload(node: SignatureDeclaration) {
|
||||
if (nodeIsPresent((node as FunctionLikeDeclaration).body)) {
|
||||
const symbol = getSymbolOfNode(node);
|
||||
const signaturesOfSymbol = getSignaturesOfSymbol(symbol);
|
||||
|
||||
@@ -1780,7 +1780,7 @@ namespace ts {
|
||||
return createArrayLiteral(expressions);
|
||||
}
|
||||
|
||||
function getParametersOfDecoratedDeclaration(node: FunctionLike, container: ClassLikeDeclaration) {
|
||||
function getParametersOfDecoratedDeclaration(node: SignatureDeclaration, container: ClassLikeDeclaration) {
|
||||
if (container && node.kind === SyntaxKind.GetAccessor) {
|
||||
const { setAccessor } = getAllAccessorDeclarations(container.members, <AccessorDeclaration>node);
|
||||
if (setAccessor) {
|
||||
|
||||
+3
-10
@@ -967,15 +967,8 @@ namespace ts {
|
||||
| SetAccessorDeclaration
|
||||
| FunctionExpression
|
||||
| ArrowFunction;
|
||||
export type FunctionLike =
|
||||
| FunctionLikeDeclaration
|
||||
| FunctionTypeNode
|
||||
| ConstructorTypeNode
|
||||
| IndexSignatureDeclaration
|
||||
| MethodSignature
|
||||
| ConstructSignatureDeclaration
|
||||
| CallSignatureDeclaration
|
||||
| JSDocFunctionType;
|
||||
/** @deprecated Use SignatureDeclaration */
|
||||
export type FunctionLike = SignatureDeclaration;
|
||||
|
||||
export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement {
|
||||
kind: SyntaxKind.FunctionDeclaration;
|
||||
@@ -2856,7 +2849,7 @@ namespace ts {
|
||||
*/
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||
isImplementationOfOverload(node: FunctionLike): boolean | undefined;
|
||||
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
isUnknownSymbol(symbol: Symbol): boolean;
|
||||
|
||||
@@ -1035,7 +1035,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
export function getContainingFunction(node: Node): FunctionLike {
|
||||
export function getContainingFunction(node: Node): SignatureDeclaration {
|
||||
return findAncestor(node.parent, isFunctionLike);
|
||||
}
|
||||
|
||||
@@ -1809,7 +1809,7 @@ namespace ts {
|
||||
return parameter && parameter.symbol;
|
||||
}
|
||||
|
||||
export function getHostSignatureFromJSDoc(node: JSDocParameterTag): FunctionLike | undefined {
|
||||
export function getHostSignatureFromJSDoc(node: JSDocParameterTag): SignatureDeclaration | undefined {
|
||||
const host = getJSDocHost(node);
|
||||
const decl = getSourceOfDefaultedAssignment(host) ||
|
||||
getSourceOfAssignment(host) ||
|
||||
@@ -2144,7 +2144,7 @@ namespace ts {
|
||||
AsyncGenerator = Async | Generator, // Function is an async generator function
|
||||
}
|
||||
|
||||
export function getFunctionFlags(node: FunctionLike | undefined) {
|
||||
export function getFunctionFlags(node: SignatureDeclaration | undefined) {
|
||||
if (!node) {
|
||||
return FunctionFlags.Invalid;
|
||||
}
|
||||
@@ -5309,7 +5309,7 @@ namespace ts {
|
||||
|
||||
// Functions
|
||||
|
||||
export function isFunctionLike(node: Node): node is FunctionLike {
|
||||
export function isFunctionLike(node: Node): node is SignatureDeclaration {
|
||||
return node && isFunctionLikeKind(node.kind);
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -644,7 +644,8 @@ declare namespace ts {
|
||||
body?: Block | Expression;
|
||||
}
|
||||
type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | FunctionExpression | ArrowFunction;
|
||||
type FunctionLike = FunctionLikeDeclaration | FunctionTypeNode | ConstructorTypeNode | IndexSignatureDeclaration | MethodSignature | ConstructSignatureDeclaration | CallSignatureDeclaration | JSDocFunctionType;
|
||||
/** @deprecated Use SignatureDeclaration */
|
||||
type FunctionLike = SignatureDeclaration;
|
||||
interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement {
|
||||
kind: SyntaxKind.FunctionDeclaration;
|
||||
name?: Identifier;
|
||||
@@ -1801,7 +1802,7 @@ declare namespace ts {
|
||||
*/
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||
isImplementationOfOverload(node: FunctionLike): boolean | undefined;
|
||||
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
isUnknownSymbol(symbol: Symbol): boolean;
|
||||
@@ -3211,7 +3212,7 @@ declare namespace ts {
|
||||
function isEntityName(node: Node): node is EntityName;
|
||||
function isPropertyName(node: Node): node is PropertyName;
|
||||
function isBindingName(node: Node): node is BindingName;
|
||||
function isFunctionLike(node: Node): node is FunctionLike;
|
||||
function isFunctionLike(node: Node): node is SignatureDeclaration;
|
||||
function isClassElement(node: Node): node is ClassElement;
|
||||
function isClassLike(node: Node): node is ClassLikeDeclaration;
|
||||
function isAccessor(node: Node): node is AccessorDeclaration;
|
||||
|
||||
+4
-3
@@ -644,7 +644,8 @@ declare namespace ts {
|
||||
body?: Block | Expression;
|
||||
}
|
||||
type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | FunctionExpression | ArrowFunction;
|
||||
type FunctionLike = FunctionLikeDeclaration | FunctionTypeNode | ConstructorTypeNode | IndexSignatureDeclaration | MethodSignature | ConstructSignatureDeclaration | CallSignatureDeclaration | JSDocFunctionType;
|
||||
/** @deprecated Use SignatureDeclaration */
|
||||
type FunctionLike = SignatureDeclaration;
|
||||
interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement {
|
||||
kind: SyntaxKind.FunctionDeclaration;
|
||||
name?: Identifier;
|
||||
@@ -1801,7 +1802,7 @@ declare namespace ts {
|
||||
*/
|
||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||
isImplementationOfOverload(node: FunctionLike): boolean | undefined;
|
||||
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
isUnknownSymbol(symbol: Symbol): boolean;
|
||||
@@ -3266,7 +3267,7 @@ declare namespace ts {
|
||||
function isEntityName(node: Node): node is EntityName;
|
||||
function isPropertyName(node: Node): node is PropertyName;
|
||||
function isBindingName(node: Node): node is BindingName;
|
||||
function isFunctionLike(node: Node): node is FunctionLike;
|
||||
function isFunctionLike(node: Node): node is SignatureDeclaration;
|
||||
function isClassElement(node: Node): node is ClassElement;
|
||||
function isClassLike(node: Node): node is ClassLikeDeclaration;
|
||||
function isAccessor(node: Node): node is AccessorDeclaration;
|
||||
|
||||
Reference in New Issue
Block a user