本文整理汇总了TypeScript中tsutils/typeguard/2.8.isPropertyDeclaration方法的典型用法代码示例。如果您正苦于以下问题:TypeScript 8.isPropertyDeclaration方法的具体用法?TypeScript 8.isPropertyDeclaration怎么用?TypeScript 8.isPropertyDeclaration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tsutils/typeguard/2.8
的用法示例。
在下文中一共展示了8.isPropertyDeclaration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: checkPropertySignatureAndIndexSignature
function checkPropertySignatureAndIndexSignature(
node: ts.Node,
ctx: Lint.WalkContext<Options>
): CheckNodeResult {
if (
(utils.isPropertySignature(node) ||
utils.isIndexSignatureDeclaration(node) ||
utils.isPropertyDeclaration(node)) &&
!(
node.modifiers &&
node.modifiers.filter(m => m.kind === ts.SyntaxKind.ReadonlyKeyword)
.length > 0
)
) {
// Check if ignore-prefix applies
if (Ignore.shouldIgnorePrefix(node, ctx.options, ctx.sourceFile)) {
return { invalidNodes: [] };
}
const start = utils.isIndexSignatureDeclaration(node)
? node.getStart(ctx.sourceFile)
: node.name.getStart(ctx.sourceFile);
return {
invalidNodes: [
createInvalidNode(node, [new Lint.Replacement(start, 0, "readonly ")])
]
};
}
return { invalidNodes: [] };
}
示例2: isVariableOrParameterOrPropertyDeclaration
export function isVariableOrParameterOrPropertyDeclaration(
node: ts.Node
): node is
| ts.VariableDeclaration
| ts.ParameterDeclaration
| ts.PropertyDeclaration {
return (
utils.isVariableDeclaration(node) ||
utils.isParameterDeclaration(node) ||
utils.isPropertyDeclaration(node)
);
}
示例3: isVariableLikeDeclaration
export function isVariableLikeDeclaration(
node: ts.Node
): node is ts.VariableLikeDeclaration {
return (
utils.isBindingElement(node) ||
utils.isEnumMember(node) ||
utils.isParameterDeclaration(node) ||
utils.isPropertyAssignment(node) ||
utils.isPropertyDeclaration(node) ||
utils.isPropertySignature(node) ||
utils.isShorthandPropertyAssignment(node) ||
utils.isVariableDeclaration(node)
);
}
示例4: return
return (node: ts.Node, ctx: Lint.WalkContext<Options>) => {
// Skip checking in functions if ignore-local is set
if (ctx.options.ignoreLocal && isFunctionLikeDeclaration(node)) {
// We still need to check the parameters and return type
const invalidNodes = checkIgnoreLocalFunctionNode(node, ctx, checkNode);
// Now skip this whole branch
return { invalidNodes, skipChildren: true };
}
// Skip checking in classes/interfaces if ignore-class/ignore-interface is set
if (
(ctx.options.ignoreClass && utils.isPropertyDeclaration(node)) ||
(ctx.options.ignoreInterface && utils.isPropertySignature(node))
) {
// Now skip this whole branch
return { invalidNodes: [], skipChildren: true };
}
// Forward to check node
return checkNode(node, ctx);
};