Ignore @private/@protected on constructor functions (#35782)

* Ignore @private on constructor functions

This was incorrect in the best of circumstances and caused a crash when
the parent of the function had no symbol, because the accessibility
check assumed it was operating on a constructor and that the parent was
always the containing class.

* Non-constructors are always accessible

Previously, all function-like kinds were accessible, which includes
constructors. This was wrong.
This commit is contained in:
Nathan Shively-Sanders
2019-12-20 08:41:52 -08:00
committed by GitHub
parent 9445657184
commit 2cc1340a7b
5 changed files with 85 additions and 2 deletions

View File

@@ -24865,8 +24865,8 @@ namespace ts {
const declaration = signature.declaration;
const modifiers = getSelectedModifierFlags(declaration, ModifierFlags.NonPublicAccessibilityModifier);
// Public constructor is accessible.
if (!modifiers) {
// (1) Public constructors and (2) constructor functions are always accessible.
if (!modifiers || declaration.kind !== SyntaxKind.Constructor) {
return true;
}