Skip to content

FunctionLike = SignatureDeclaration #22365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14089,7 +14089,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 :
Expand All @@ -14107,7 +14107,7 @@ namespace ts {
});
}

function getContextualThisParameterType(func: FunctionLike): Type {
function getContextualThisParameterType(func: SignatureDeclaration): Type {
if (func.kind === SyntaxKind.ArrowFunction) {
return undefined;
}
Expand Down Expand Up @@ -14304,7 +14304,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 ||
Expand Down Expand Up @@ -20634,12 +20634,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;
}
Expand Down Expand Up @@ -20701,7 +20701,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) {
Expand Down Expand Up @@ -22668,12 +22668,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
Expand Down Expand Up @@ -25395,7 +25395,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);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 3 additions & 10 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2855,7 +2848,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;
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ namespace ts {
});
}

export function getContainingFunction(node: Node): FunctionLike {
export function getContainingFunction(node: Node): SignatureDeclaration {
return findAncestor(node.parent, isFunctionLike);
}

Expand Down Expand Up @@ -1700,7 +1700,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 = getSourceOfAssignment(host) ||
getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
Expand Down Expand Up @@ -2024,7 +2024,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;
}
Expand Down Expand Up @@ -5188,7 +5188,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);
}

Expand Down
7 changes: 4 additions & 3 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3215,7 +3216,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;
Expand Down
7 changes: 4 additions & 3 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3270,7 +3271,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;
Expand Down