本文整理匯總了TypeScript中@babel/types.isClassMethod函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isClassMethod函數的具體用法?TypeScript isClassMethod怎麽用?TypeScript isClassMethod使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isClassMethod函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getConstructorClassMethod
export function getConstructorClassMethod(astNode: babel.Class):
babel.ClassMethod|undefined {
for (const member of astNode.body.body) {
if (babel.isClassMethod(member) && member.kind === 'constructor') {
return member;
}
}
}
示例2: _getMethods
function* _getMethods(node: babel.Node) {
if (!babel.isClassDeclaration(node) && !babel.isClassExpression(node)) {
return;
}
for (const statement of node.body.body) {
if (babel.isClassMethod(statement) && statement.kind === 'method') {
yield statement;
}
}
}
示例3: extractPropertyFromGetterOrSetter
export function extractPropertyFromGetterOrSetter(
method: babel.ClassMethod|babel.ObjectMethod,
jsdocAnn: jsdoc.Annotation|undefined,
document: JavaScriptDocument): ScannedProperty|null {
// TODO(43081j): remove this when static properties are supported
if (babel.isClassMethod(method) && method.static) {
return null;
}
if (method.kind !== 'get' && method.kind !== 'set') {
return null;
}
// TODO(43081j): use getPropertyName, see
// https://github.com/Polymer/polymer-analyzer/pull/867
const name = getPropertyName(method);
if (name === undefined) {
return null;
}
let type;
let description;
let privacy: Privacy = 'public';
let readOnly = false;
if (jsdocAnn) {
const ret = getReturnFromAnnotation(jsdocAnn);
type = ret ? ret.type : undefined;
description = jsdoc.getDescription(jsdocAnn);
privacy = getOrInferPrivacy(name, jsdocAnn);
readOnly = jsdoc.hasTag(jsdocAnn, 'readonly');
}
return {
name,
astNode: {language: 'js', node: method, containingDocument: document},
type,
jsdoc: jsdocAnn,
sourceRange: document.sourceRangeForNode(method)!,
description,
privacy,
warnings: [],
readOnly,
};
}
示例4: getIdentifierName
(n) => babel.isClassMethod(n) && n.static === true &&
n.kind === 'get' && getIdentifierName(n.key) === name) as