How to use the @ts-morph/common.getSyntaxKindName function in @ts-morph/common

To help you get started, we’ve selected a few @ts-morph/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / utils / CommentNodeParser.ts View on Github external
function getTokenEnd(node: ts.Node, kind: SyntaxKind.OpenBraceToken | SyntaxKind.ColonToken) {
            // @code-fence-allow(getChildren): Ok, not searching for comments.
            const token = node.getChildren(sourceFile).find(c => c.kind === kind);
            if (token == null)
                throw new errors.NotImplementedError(`Unexpected scenario where a(n) ${getSyntaxKindName(kind)} was not found.`);
            return token.end;
        }
    }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / utils / CommentNodeParser.ts View on Github external
function getCtor() {
            if (isStatementContainerNode(container))
                return CompilerCommentStatement;
            if (ts.isClassLike(container))
                return CompilerCommentClassElement;
            if (ts.isInterfaceDeclaration(container) || ts.isTypeLiteralNode(container))
                return CompilerCommentTypeElement;
            if (ts.isObjectLiteralExpression(container))
                return CompilerCommentObjectLiteralElement;
            if (ts.isEnumDeclaration(container))
                return CompilerCommentEnumMember;

            throw new errors.NotImplementedError(`Not implemented comment node container type: ${getSyntaxKindName(container.kind)}`);
        }
    }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / HeritageClauseableNode.ts View on Github external
getHeritageClauseByKindOrThrow(kind: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword) {
            return errors.throwIfNullOrUndefined(this.getHeritageClauseByKind(kind), `Expected to have heritage clause of kind ${getSyntaxKindName(kind)}.`);
        }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / initializer / InitializerExpressionGetableNode.ts View on Github external
getInitializerIfKindOrThrow(kind: TKind) {
            return errors.throwIfNullOrUndefined(this.getInitializerIfKind(kind), `Expected to find an initializer of kind '${getSyntaxKindName(kind)}'.`);
        }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / expression / expressioned / ExpressionedNode.ts View on Github external
getExpressionIfKindOrThrow(kind: TKind): KindToExpressionMappings[TKind] {
            return errors.throwIfNullOrUndefined(this.getExpressionIfKind(kind), `An expression of the kind ${getSyntaxKindName(kind)} was expected.`);
        }