How to use the @ts-morph/common.errors.NotImplementedError 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 / jsx / JsxElement.ts View on Github external
set(structure: Partial) {
        callBaseSet(JsxElementBase.prototype, this, structure);

        if (structure.attributes != null) {
            const openingElement = this.getOpeningElement();
            openingElement.getAttributes().forEach(a => a.remove());
            openingElement.addAttributes(structure.attributes);
        }

        // todo: deprecate bodyText when implementing this
        if (structure.children != null)
            throw new errors.NotImplementedError("Setting JSX children is currently not implemented. Please open an issue if you need this.");

        if (structure.bodyText != null)
            this.setBodyText(structure.bodyText);
        else if (structure.hasOwnProperty(nameof(structure.bodyText)))
            this.setBodyTextInline("");

        if (structure.name != null) {
            this.getOpeningElement().getTagNameNode().replaceWithText(structure.name);
            this.getClosingElement().getTagNameNode().replaceWithText(structure.name);
        }

        return this;
    }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / GeneratorableNode.ts View on Github external
function getAsteriskInsertPos(node: Node) {
    if (node.getKind() === SyntaxKind.FunctionDeclaration)
        return node.getFirstChildByKindOrThrow(SyntaxKind.FunctionKeyword).getEnd();

    const namedNode = node as any as NamedNode;

    /* istanbul ignore if */
    if (namedNode.getName == null)
        throw new errors.NotImplementedError("Expected a name node for a non-function declaration.");

    return namedNode.getNameNode().getStart();
}
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / AwaitableNode.ts View on Github external
function getAwaitInsertPos(node: Node) {
    if (node.getKind() === SyntaxKind.ForOfStatement)
        return node.getFirstChildByKindOrThrow(SyntaxKind.ForKeyword).getEnd();

    throw new errors.NotImplementedError("Expected a for of statement node.");
}
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / export / ExportGetableNode.ts View on Github external
function throwForNotModifierableNode(): never {
    throw new errors.NotImplementedError(`Not implemented situation where node was not a ${nameof(ModifierableNode)}.`);
}
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / name / RenameableNode.ts View on Github external
function getNodeToRename(thisNode: Node) {
                if (TypeGuards.isIdentifier(thisNode))
                    return thisNode;
                else if ((thisNode as any).getNameNode != null) {
                    const node = (thisNode as any).getNameNode() as Node;
                    errors.throwIfNullOrUndefined(node, "Expected to find a name node when renaming.");
                    if (TypeGuards.isArrayBindingPattern(node) || TypeGuards.isObjectBindingPattern(node))
                        throw new errors.NotImplementedError(`Not implemented renameable scenario for ${node.getKindName()}.`);
                    return node;
                }
                else {
                    throw new errors.NotImplementedError(`Not implemented renameable scenario for ${thisNode.getKindName()}`);
                }
            }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / TypeParameteredNode.ts View on Github external
function getInsertPos(node: TypeParameteredNode & Node) {
    const namedNode = node as any as (NamedNode & Node);
    if (namedNode.getNameNode != null)
        return namedNode.getNameNode().getEnd();
    else if (TypeGuards.isCallSignatureDeclaration(node) || TypeGuards.isFunctionTypeNode(node))
        return node.getFirstChildByKindOrThrow(SyntaxKind.OpenParenToken).getStart();
    else
        throw new errors.NotImplementedError(`Not implemented scenario inserting type parameters for node with kind ${node.getKindName()}.`);
}
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / ReturnTypedNode.ts View on Github external
getSignature() {
            const signature = this._context.typeChecker.getSignatureFromNode(this);
            if (signature == null)
                throw new errors.NotImplementedError("Expected the node to have a signature.");
            return signature;
        }