Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getImportDeclarationOrThrow(conditionOrModuleSpecifier: string | ((importDeclaration: ImportDeclaration) => boolean)) {
return errors.throwIfNullOrUndefined(
this.getImportDeclaration(conditionOrModuleSpecifier),
"Expected to find an import with the provided condition."
);
}
getMemberOrThrow(name: string): Symbol {
return errors.throwIfNullOrUndefined(this.getMember(name), `Expected to find member with name: ${name}`);
}
getConstructSignatureOrThrow(findFunction: (member: ConstructSignatureDeclaration) => boolean) {
return errors.throwIfNullOrUndefined(
this.getConstructSignature(findFunction),
"Expected to find a construct signature with the provided condition."
);
}
getTypeNodeOrThrow() {
return errors.throwIfNullOrUndefined(this.getTypeNode(), "Expected to find a type node.");
}
getLocalTargetSymbolOrThrow() {
return errors.throwIfNullOrUndefined(this.getLocalTargetSymbol(), `The export specifier's local target symbol was expected.`);
}
getDefaultImportOrThrow() {
return errors.throwIfNullOrUndefined(this.getDefaultImport(), "Expected to find a default import.");
}
getInitializerOrThrow() {
return errors.throwIfNullOrUndefined(this.getInitializer(), `Expected to find an initializer for the JSX attribute '${this.getName()}'`);
}
getNameNodeOrThrow() {
return errors.throwIfNullOrUndefined(this.getNameNode(), "Expected to have a name node.");
}
getExportOrThrow(name: string): Symbol {
return errors.throwIfNullOrUndefined(this.getExport(name), `Expected to find export with name: ${name}`);
}
getParameterOrThrow(nameOrFindFunction: string | ((declaration: ParameterDeclaration) => boolean)): ParameterDeclaration {
return errors.throwIfNullOrUndefined(this.getParameter(nameOrFindFunction),
() => getNotFoundErrorMessageForNameOrFindFunction("parameter", nameOrFindFunction));
}