Comparing version 0.23.14 to 0.23.15
@@ -107,3 +107,3 @@ import * as ts from "typescript"; | ||
/** @internal */ | ||
convertSymbol(context: Context, symbol: ts.Symbol): void; | ||
convertSymbol(context: Context, symbol: ts.Symbol, exportSymbol?: ts.Symbol): void; | ||
/** | ||
@@ -110,0 +110,0 @@ * Convert the given TypeScript type into its TypeDoc type reflection. |
@@ -75,4 +75,4 @@ "use strict"; | ||
/** @internal */ | ||
convertSymbol(context, symbol) { | ||
(0, symbols_1.convertSymbol)(context, symbol); | ||
convertSymbol(context, symbol, exportSymbol) { | ||
(0, symbols_1.convertSymbol)(context, symbol, exportSymbol); | ||
} | ||
@@ -79,0 +79,0 @@ /** |
@@ -18,3 +18,8 @@ "use strict"; | ||
: context.scope.name, kind, context.scope); | ||
if (declaration) { | ||
// If we are creating signatures for a variable and the variable has a comment associated with it | ||
// then we should prefer that variable's comment over any comment on the signature. The comment plugin | ||
// will copy the comment down if this signature doesn't have one, so don't set one. | ||
if (declaration && | ||
(!context.scope.comment || | ||
!(context.scope.conversionFlags & models_1.ConversionFlags.VariableSource))) { | ||
sigRef.comment = (0, comments_1.getSignatureComment)(declaration, context.converter.config, context.logger, context.converter.commentStyle); | ||
@@ -21,0 +26,0 @@ } |
@@ -19,2 +19,10 @@ "use strict"; | ||
} | ||
// If the typedef tag is just referring to another type-space symbol, with no type parameters | ||
// or appropriate forwarding type parameters, then we treat it as a re-export instead of creating | ||
// a type alias with an import type. | ||
const aliasedSymbol = getTypedefReExportTarget(context, declaration); | ||
if (aliasedSymbol) { | ||
context.converter.convertSymbol(context, aliasedSymbol, exportSymbol ?? symbol); | ||
return; | ||
} | ||
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol); | ||
@@ -73,1 +81,34 @@ reflection.comment = (0, comments_1.getJsDocComment)(declaration, context.converter.config, context.logger); | ||
} | ||
function getTypedefReExportTarget(context, declaration) { | ||
const typeExpression = declaration.typeExpression; | ||
if (!ts.isJSDocTypedefTag(declaration) || | ||
!typeExpression || | ||
ts.isJSDocTypeLiteral(typeExpression) || | ||
!ts.isImportTypeNode(typeExpression.type) || | ||
!typeExpression.type.qualifier || | ||
!ts.isIdentifier(typeExpression.type.qualifier)) { | ||
return; | ||
} | ||
const targetSymbol = context.expectSymbolAtLocation(typeExpression.type.qualifier); | ||
const decl = targetSymbol.declarations?.[0]; | ||
if (!decl || | ||
!(ts.isTypeAliasDeclaration(decl) || | ||
ts.isInterfaceDeclaration(decl) || | ||
ts.isJSDocTypedefTag(decl) || | ||
ts.isJSDocCallbackTag(decl))) { | ||
return; | ||
} | ||
const targetParams = ts.getEffectiveTypeParameterDeclarations(decl); | ||
const localParams = ts.getEffectiveTypeParameterDeclarations(declaration); | ||
const localArgs = typeExpression.type.typeArguments || []; | ||
// If we have type parameters, ensure they are forwarding parameters with no transformations. | ||
// This doesn't check constraints since they aren't checked in JSDoc types. | ||
if (targetParams.length !== localParams.length || | ||
localArgs.some((arg, i) => !ts.isTypeReferenceNode(arg) || | ||
!ts.isIdentifier(arg.typeName) || | ||
arg.typeArguments || | ||
localParams[i]?.name.text !== arg.typeName.text)) { | ||
return; | ||
} | ||
return targetSymbol; | ||
} |
@@ -480,2 +480,3 @@ "use strict"; | ||
setModifiers(symbol, accessDeclaration, reflection); | ||
reflection.conversionFlags |= models_1.ConversionFlags.VariableSource; | ||
context.finalizeDeclarationReflection(reflection); | ||
@@ -482,0 +483,0 @@ const reflectionContext = context.withScope(reflection); |
@@ -12,2 +12,3 @@ "use strict"; | ||
const symbols_1 = require("./symbols"); | ||
const nodes_1 = require("./utils/nodes"); | ||
const reflections_1 = require("./utils/reflections"); | ||
@@ -580,3 +581,3 @@ const converters = new Map(); | ||
const resolved = resolveReference(type); | ||
assert(isObjectType(resolved)); | ||
assert((0, nodes_1.isObjectType)(resolved)); | ||
const args = context.checker | ||
@@ -650,7 +651,4 @@ .getTypeArguments(type) | ||
} | ||
function isObjectType(type) { | ||
return typeof type.objectFlags === "number"; | ||
} | ||
function resolveReference(type) { | ||
if (isObjectType(type) && type.objectFlags & ts.ObjectFlags.Reference) { | ||
if ((0, nodes_1.isObjectType)(type) && type.objectFlags & ts.ObjectFlags.Reference) { | ||
return type.target; | ||
@@ -657,0 +655,0 @@ } |
@@ -6,1 +6,2 @@ import * as ts from "typescript"; | ||
export declare function getHeritageTypes(declarations: readonly (ts.ClassDeclaration | ts.InterfaceDeclaration)[], kind: ts.SyntaxKind.ImplementsKeyword | ts.SyntaxKind.ExtendsKeyword): ts.ExpressionWithTypeArguments[]; | ||
export declare function isObjectType(type: ts.Type): type is ts.ObjectType; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getHeritageTypes = exports.isNamedNode = void 0; | ||
exports.isObjectType = exports.getHeritageTypes = exports.isNamedNode = void 0; | ||
const ts = require("typescript"); | ||
@@ -25,1 +25,5 @@ function isNamedNode(node) { | ||
exports.getHeritageTypes = getHeritageTypes; | ||
function isObjectType(type) { | ||
return typeof type.objectFlags === "number"; | ||
} | ||
exports.isObjectType = isObjectType; |
@@ -29,2 +29,9 @@ import type * as ts from "typescript"; | ||
/** | ||
* @internal | ||
*/ | ||
export declare enum ConversionFlags { | ||
None = 0, | ||
VariableSource = 1 | ||
} | ||
/** | ||
* A reflection that represents a single declaration emitted by the TypeScript compiler. | ||
@@ -122,2 +129,7 @@ * | ||
version?: string; | ||
/** | ||
* Flags for information about a reflection which is needed solely during conversion. | ||
* @internal | ||
*/ | ||
conversionFlags: ConversionFlags; | ||
hasGetterOrSetter(): boolean; | ||
@@ -124,0 +136,0 @@ getAllSignatures(): SignatureReflection[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DeclarationReflection = void 0; | ||
exports.DeclarationReflection = exports.ConversionFlags = void 0; | ||
const types_1 = require("../types"); | ||
@@ -8,2 +8,10 @@ const abstract_1 = require("./abstract"); | ||
/** | ||
* @internal | ||
*/ | ||
var ConversionFlags; | ||
(function (ConversionFlags) { | ||
ConversionFlags[ConversionFlags["None"] = 0] = "None"; | ||
ConversionFlags[ConversionFlags["VariableSource"] = 1] = "VariableSource"; | ||
})(ConversionFlags = exports.ConversionFlags || (exports.ConversionFlags = {})); | ||
/** | ||
* A reflection that represents a single declaration emitted by the TypeScript compiler. | ||
@@ -15,2 +23,10 @@ * | ||
class DeclarationReflection extends container_1.ContainerReflection { | ||
constructor() { | ||
super(...arguments); | ||
/** | ||
* Flags for information about a reflection which is needed solely during conversion. | ||
* @internal | ||
*/ | ||
this.conversionFlags = ConversionFlags.None; | ||
} | ||
hasGetterOrSetter() { | ||
@@ -17,0 +33,0 @@ return !!this.getSignature || !!this.setSignature; |
export { Reflection, ReflectionFlag, ReflectionFlags, TraverseProperty, } from "./abstract"; | ||
export type { TraverseCallback } from "./abstract"; | ||
export { ContainerReflection } from "./container"; | ||
export { DeclarationReflection } from "./declaration"; | ||
export { DeclarationReflection, ConversionFlags } from "./declaration"; | ||
export type { DeclarationHierarchy } from "./declaration"; | ||
@@ -6,0 +6,0 @@ export { ReflectionKind } from "./kind"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.splitUnquotedString = exports.VarianceModifier = exports.TypeParameterReflection = exports.SignatureReflection = exports.ReferenceReflection = exports.ProjectReflection = exports.ParameterReflection = exports.ReflectionKind = exports.DeclarationReflection = exports.ContainerReflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.Reflection = void 0; | ||
exports.splitUnquotedString = exports.VarianceModifier = exports.TypeParameterReflection = exports.SignatureReflection = exports.ReferenceReflection = exports.ProjectReflection = exports.ParameterReflection = exports.ReflectionKind = exports.ConversionFlags = exports.DeclarationReflection = exports.ContainerReflection = exports.TraverseProperty = exports.ReflectionFlags = exports.ReflectionFlag = exports.Reflection = void 0; | ||
var abstract_1 = require("./abstract"); | ||
@@ -13,2 +13,3 @@ Object.defineProperty(exports, "Reflection", { enumerable: true, get: function () { return abstract_1.Reflection; } }); | ||
Object.defineProperty(exports, "DeclarationReflection", { enumerable: true, get: function () { return declaration_1.DeclarationReflection; } }); | ||
Object.defineProperty(exports, "ConversionFlags", { enumerable: true, get: function () { return declaration_1.ConversionFlags; } }); | ||
var kind_1 = require("./kind"); | ||
@@ -15,0 +16,0 @@ Object.defineProperty(exports, "ReflectionKind", { enumerable: true, get: function () { return kind_1.ReflectionKind; } }); |
@@ -29,3 +29,3 @@ import type { RendererHooks } from "../.."; | ||
header: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement; | ||
hierarchy: (props: import("../../../models").DeclarationHierarchy | undefined) => import("../../../utils/jsx.elements").JsxElement; | ||
hierarchy: (props: import("../../../models").DeclarationHierarchy | undefined) => import("../../../utils/jsx.elements").JsxElement | undefined; | ||
index: (props: import("../../../models").ContainerReflection) => import("../../../utils/jsx.elements").JsxElement; | ||
@@ -32,0 +32,0 @@ member: (props: import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement; |
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import type { DeclarationHierarchy } from "../../../../models"; | ||
export declare const hierarchy: (context: DefaultThemeRenderContext, props: DeclarationHierarchy | undefined) => JSX.Element; | ||
export declare function hierarchy(context: DefaultThemeRenderContext, props: DeclarationHierarchy | undefined): JSX.Element | undefined; |
@@ -5,7 +5,14 @@ "use strict"; | ||
const utils_1 = require("../../../../utils"); | ||
const hierarchy = (context, props) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, !!props && (utils_1.JSX.createElement("section", { class: "tsd-panel tsd-hierarchy" }, | ||
utils_1.JSX.createElement("h4", null, "Hierarchy"), | ||
utils_1.JSX.createElement("ul", { class: "tsd-hierarchy" }, props.types.map((item, i, l) => (utils_1.JSX.createElement("li", null, | ||
function hierarchy(context, props) { | ||
if (!props) | ||
return; | ||
return (utils_1.JSX.createElement("section", { class: "tsd-panel tsd-hierarchy" }, | ||
utils_1.JSX.createElement("h4", null, "Hierarchy"), | ||
hierarchyList(context, props))); | ||
} | ||
exports.hierarchy = hierarchy; | ||
function hierarchyList(context, props) { | ||
return (utils_1.JSX.createElement("ul", { class: "tsd-hierarchy" }, props.types.map((item, i, l) => (utils_1.JSX.createElement("li", null, | ||
props.isTarget ? utils_1.JSX.createElement("span", { class: "target" }, item.toString()) : context.type(item), | ||
i === l.length - 1 && !!props.next && context.hierarchy(props.next))))))))); | ||
exports.hierarchy = hierarchy; | ||
i === l.length - 1 && !!props.next && hierarchyList(context, props.next)))))); | ||
} |
@@ -22,5 +22,3 @@ "use strict"; | ||
context.comment(props), | ||
(0, lib_1.hasTypeParameters)(props) && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, | ||
utils_1.JSX.createElement("h4", { class: "tsd-type-parameters-title" }, "Type Parameters"), | ||
context.typeParameters(props.typeParameters))), | ||
(0, lib_1.hasTypeParameters)(props) && context.typeParameters(props.typeParameters), | ||
props.type instanceof models_1.ReflectionType && (utils_1.JSX.createElement("div", { class: "tsd-type-declaration" }, | ||
@@ -27,0 +25,0 @@ utils_1.JSX.createElement("h4", null, "Type declaration"), |
@@ -10,5 +10,3 @@ "use strict"; | ||
context.comment(props), | ||
(0, lib_1.hasTypeParameters)(props) && (utils_1.JSX.createElement("div", { class: "tsd-type-parameters" }, | ||
utils_1.JSX.createElement("h4", { class: "tsd-type-parameters-title" }, "Type Parameters"), | ||
context.typeParameters(props.typeParameters))), | ||
(0, lib_1.hasTypeParameters)(props) && context.typeParameters(props.typeParameters), | ||
props.parameters && props.parameters.length > 0 && (utils_1.JSX.createElement("div", { class: "tsd-parameters" }, | ||
@@ -15,0 +13,0 @@ utils_1.JSX.createElement("h4", { class: "tsd-parameters-title" }, "Parameters"), |
{ | ||
"name": "typedoc", | ||
"description": "Create api documentation for TypeScript projects.", | ||
"version": "0.23.14", | ||
"version": "0.23.15", | ||
"homepage": "https://typedoc.org", | ||
@@ -6,0 +6,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1021927
24144
291