Move isObjectLiteralElement to public utilities (#20605)

This commit is contained in:
Andy
2018-01-08 12:29:21 -08:00
committed by GitHub
parent 97c3e9c3ef
commit 6d361f89e3
4 changed files with 17 additions and 14 deletions

View File

@@ -5847,4 +5847,19 @@ namespace ts {
export function hasOnlyExpressionInitializer(node: Node): node is HasExpressionInitializer {
return hasInitializer(node) && !isForStatement(node) && !isForInStatement(node) && !isForOfStatement(node) && !isJsxAttribute(node);
}
export function isObjectLiteralElement(node: Node): node is ObjectLiteralElement {
switch (node.kind) {
case SyntaxKind.JsxAttribute:
case SyntaxKind.JsxSpreadAttribute:
case SyntaxKind.PropertyAssignment:
case SyntaxKind.ShorthandPropertyAssignment:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return true;
default:
return false;
}
}
}

View File

@@ -2251,20 +2251,6 @@ namespace ts {
isLiteralComputedPropertyDeclarationName(node);
}
function isObjectLiteralElement(node: Node): node is ObjectLiteralElement {
switch (node.kind) {
case SyntaxKind.JsxAttribute:
case SyntaxKind.JsxSpreadAttribute:
case SyntaxKind.PropertyAssignment:
case SyntaxKind.ShorthandPropertyAssignment:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return true;
}
return false;
}
/**
* Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 }
*/

View File

@@ -3104,6 +3104,7 @@ declare namespace ts {
function isJSDocCommentContainingNode(node: Node): boolean;
function isSetAccessor(node: Node): node is SetAccessorDeclaration;
function isGetAccessor(node: Node): node is GetAccessorDeclaration;
function isObjectLiteralElement(node: Node): node is ObjectLiteralElement;
}
declare namespace ts {
type ErrorCallback = (message: DiagnosticMessage, length: number) => void;

View File

@@ -3157,6 +3157,7 @@ declare namespace ts {
function isJSDocCommentContainingNode(node: Node): boolean;
function isSetAccessor(node: Node): node is SetAccessorDeclaration;
function isGetAccessor(node: Node): node is GetAccessorDeclaration;
function isObjectLiteralElement(node: Node): node is ObjectLiteralElement;
}
declare namespace ts {
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;