diff --git a/.config/.prettierignore b/.config/.prettierignore index b939d452b..74c80122f 100644 --- a/.config/.prettierignore +++ b/.config/.prettierignore @@ -8,6 +8,7 @@ ../src/test/renderer/specs ../src/test/renderer/testProject ../src/test/utils/options/readers/data/invalid2.json +../src/test/converter2/behavior/constTypeParam.ts ../static/main.js ../example/docs/ **/tmp diff --git a/src/lib/converter/factories/signature.ts b/src/lib/converter/factories/signature.ts index ad1062036..3d6719957 100644 --- a/src/lib/converter/factories/signature.ts +++ b/src/lib/converter/factories/signature.ts @@ -284,10 +284,10 @@ function convertTypeParameters( // There's no way to determine directly from a ts.TypeParameter what it's variance modifiers are // so unfortunately we have to go back to the node for this... - const variance = getVariance( - param.getSymbol()?.declarations?.find(ts.isTypeParameterDeclaration) - ?.modifiers - ); + const declaration = param + .getSymbol() + ?.declarations?.find(ts.isTypeParameterDeclaration); + const variance = getVariance(declaration?.modifiers); const paramRefl = new TypeParameterReflection( param.symbol.name, @@ -296,6 +296,16 @@ function convertTypeParameters( parent, variance ); + + // No way to determine this from the type parameter itself, need to go back to the declaration + if ( + declaration?.modifiers?.some( + (m) => m.kind === ts.SyntaxKind.ConstKeyword + ) + ) { + paramRefl.flags.setFlag(ReflectionFlag.Const, true); + } + context.registerReflection(paramRefl, param.getSymbol()); context.trigger(ConverterEvents.CREATE_TYPE_PARAMETER, paramRefl); @@ -329,6 +339,10 @@ export function createTypeParamReflection( context.scope, getVariance(param.modifiers) ); + if (param.modifiers?.some((m) => m.kind === ts.SyntaxKind.ConstKeyword)) { + paramRefl.flags.setFlag(ReflectionFlag.Const, true); + } + context.registerReflection(paramRefl, param.symbol); if (ts.isJSDocTemplateTag(param.parent)) { diff --git a/src/lib/output/themes/default/partials/typeParameters.tsx b/src/lib/output/themes/default/partials/typeParameters.tsx index fa4065a41..0b1d9d8b6 100644 --- a/src/lib/output/themes/default/partials/typeParameters.tsx +++ b/src/lib/output/themes/default/partials/typeParameters.tsx @@ -11,6 +11,7 @@ export function typeParameters(context: DefaultThemeRenderContext, typeParameter {typeParameters?.map((item) => (