in src/assembler.ts [1428:1471]
private _isPrivateOrInternal(symbol: ts.Symbol, validateDeclaration?: ts.Declaration): boolean {
const hasInternalJsDocTag = _hasInternalJsDocTag(symbol);
const hasInternalSymbolName = isInternalSymbol(symbol);
const hasUnderscorePrefix = !hasInternalSymbolName && symbol.name.startsWith('_');
if (_isPrivate(symbol)) {
LOG.trace(`${chalk.cyan(symbol.name)} is marked "private", or is an unexported type declaration`);
return true;
}
// If all the declarations are marked with `@jsii ignore`, then this is effetcively private as far as jsii is concerned.
if (
symbol.declarations?.every((decl) => Directives.of(decl, (diag) => this._diagnostics.push(diag)).ignore != null)
) {
return true;
}
if (!hasInternalJsDocTag && !hasUnderscorePrefix) {
return false;
}
// We only validate if we have a declaration and the symbol doesn't have an internal name.
if (validateDeclaration && !hasInternalSymbolName) {
if (!hasUnderscorePrefix) {
this._diagnostics.push(
JsiiDiagnostic.JSII_8005_INTERNAL_UNDERSCORE.create(
ts.getNameOfDeclaration(validateDeclaration) ?? validateDeclaration,
symbol.name,
),
);
}
if (!hasInternalJsDocTag) {
this._diagnostics.push(
JsiiDiagnostic.JSII_8006_UNDERSCORE_INTERNAL.create(
ts.getNameOfDeclaration(validateDeclaration) ?? validateDeclaration,
symbol.name,
),
);
}
}
return true;
}