How to use the @ts-morph/common.errors.throwIfNullOrUndefined 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 / base / ModuledNode.ts View on Github external
getImportDeclarationOrThrow(conditionOrModuleSpecifier: string | ((importDeclaration: ImportDeclaration) => boolean)) {
            return errors.throwIfNullOrUndefined(
                this.getImportDeclaration(conditionOrModuleSpecifier),
                "Expected to find an import with the provided condition."
            );
        }
github dsherret / ts-morph / packages / ts-morph / src / compiler / symbols / Symbol.ts View on Github external
getMemberOrThrow(name: string): Symbol {
        return errors.throwIfNullOrUndefined(this.getMember(name), `Expected to find member with name: ${name}`);
    }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / TypeElementMemberedNode.ts View on Github external
getConstructSignatureOrThrow(findFunction: (member: ConstructSignatureDeclaration) => boolean) {
            return errors.throwIfNullOrUndefined(
                this.getConstructSignature(findFunction),
                "Expected to find a construct signature with the provided condition."
            );
        }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / TypedNode.ts View on Github external
getTypeNodeOrThrow() {
            return errors.throwIfNullOrUndefined(this.getTypeNode(), "Expected to find a type node.");
        }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / module / ExportSpecifier.ts View on Github external
getLocalTargetSymbolOrThrow() {
        return errors.throwIfNullOrUndefined(this.getLocalTargetSymbol(), `The export specifier's local target symbol was expected.`);
    }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / module / ImportClause.ts View on Github external
getDefaultImportOrThrow() {
        return errors.throwIfNullOrUndefined(this.getDefaultImport(), "Expected to find a default import.");
    }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / jsx / JsxAttribute.ts View on Github external
getInitializerOrThrow() {
        return errors.throwIfNullOrUndefined(this.getInitializer(), `Expected to find an initializer for the JSX attribute '${this.getName()}'`);
    }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / name / NameableNode.ts View on Github external
getNameNodeOrThrow() {
            return errors.throwIfNullOrUndefined(this.getNameNode(), "Expected to have a name node.");
        }
github dsherret / ts-morph / packages / ts-morph / src / compiler / symbols / Symbol.ts View on Github external
getExportOrThrow(name: string): Symbol {
        return errors.throwIfNullOrUndefined(this.getExport(name), `Expected to find export with name: ${name}`);
    }
github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / base / ParameteredNode.ts View on Github external
getParameterOrThrow(nameOrFindFunction: string | ((declaration: ParameterDeclaration) => boolean)): ParameterDeclaration {
            return errors.throwIfNullOrUndefined(this.getParameter(nameOrFindFunction),
                () => getNotFoundErrorMessageForNameOrFindFunction("parameter", nameOrFindFunction));
        }