From d1a9bca8ecd0fa50f3a7f946ed73f2160a8118fd Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Sat, 3 Apr 2021 13:48:35 -0600 Subject: [PATCH] fix: Handle #private getters + methods Improves support for TS 4.3. No test yet since TD doesn't support beta versions officially. Resolves #1564 --- src/lib/converter/symbols.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lib/converter/symbols.ts b/src/lib/converter/symbols.ts index 1bd7ef269..cf6136e0b 100644 --- a/src/lib/converter/symbols.ts +++ b/src/lib/converter/symbols.ts @@ -585,13 +585,6 @@ function convertProperty( parameterType = declaration.type; } setModifiers(symbol, declaration, reflection); - const parentSymbol = context.project.getSymbolFromReflection( - context.scope - ); - assert(parentSymbol, "Tried to convert a property without a parent."); - if (ts.isPrivateIdentifier(declaration.name)) { - reflection.setFlag(ReflectionFlag.Private); - } } reflection.defaultValue = declaration && convertDefaultValue(declaration); @@ -913,8 +906,16 @@ function setModifiers( reflection: Reflection ) { const modifiers = ts.getCombinedModifierFlags(declaration); - // Note: We only set this flag if the modifier is present because we allow - // fake "private" or "protected" members via @private and @protected + + if ( + ts.isMethodDeclaration(declaration) || + ts.isPropertyDeclaration(declaration) || + ts.isAccessor(declaration) + ) { + if (ts.isPrivateIdentifier(declaration.name)) { + reflection.setFlag(ReflectionFlag.Private); + } + } if (hasAllFlags(modifiers, ts.ModifierFlags.Private)) { reflection.setFlag(ReflectionFlag.Private); }