Skip to content

Commit 7ca0098

Browse files
committed
chore: remove check for declaration
1 parent 0fb7128 commit 7ca0098

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

misc/structured-types/src/SymbolParser.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ export class SymbolParser implements ISymbolParser {
501501
): PropType | null {
502502
const symbolDeclaration =
503503
symbol.valueDeclaration || symbol.declarations?.[0];
504-
if (symbolDeclaration) {
504+
if (true) {
505505
const symbolType = getSymbolType(this.checker, symbol);
506506

507507
const typeSymbol = symbolType
@@ -513,7 +513,7 @@ export class SymbolParser implements ISymbolParser {
513513
if ((declaration as ts.ParameterDeclaration).questionToken) {
514514
prop.optional = true;
515515
}
516-
if (declaration.modifiers) {
516+
if (declaration?.modifiers) {
517517
for (const m of declaration.modifiers) {
518518
if (m.kind === ts.SyntaxKind.PrivateKeyword) {
519519
prop.visibility = 'private';
@@ -530,7 +530,7 @@ export class SymbolParser implements ISymbolParser {
530530
}
531531
}
532532
}
533-
if ('name' in declaration) {
533+
if (declaration) {
534534
prop.displayName = getDeclarationName(declaration);
535535
}
536536
if (symbolType) {

misc/structured-types/src/frameworks/react.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const typeResolver: TypeResolver = (
1515
...reactOptions,
1616
};
1717
if ((symbolType.flags & ts.TypeFlags.Object) === ts.TypeFlags.Object) {
18-
if (isObjectTypeDeclaration(declaration)) {
18+
if (declaration && isObjectTypeDeclaration(declaration)) {
1919
const heritage = declaration.heritageClauses;
2020
if (heritage?.length) {
2121
const extendsFrom = heritage[0];

misc/structured-types/src/ts-utils.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export type DocsOptions = CompileOptions & ParseOptions;
218218

219219
export type TypeResolver = (props: {
220220
symbolType: ts.Type;
221-
declaration: ts.Declaration;
221+
declaration?: ts.Declaration;
222222
checker: ts.TypeChecker;
223223
}) => { type: ts.Type | undefined; intializer?: ts.Node; name?: string };
224224

@@ -296,12 +296,14 @@ export interface ISymbolParser {
296296
}
297297

298298
export const getInitializer = (
299-
declaration: ts.Node,
299+
declaration?: ts.Node,
300300
): ts.Expression | undefined =>
301-
isVariableLikeDeclaration(declaration)
302-
? declaration?.initializer
303-
: ts.isBinaryExpression(declaration.parent)
304-
? declaration.parent.right
301+
declaration
302+
? isVariableLikeDeclaration(declaration)
303+
? declaration?.initializer
304+
: ts.isBinaryExpression(declaration.parent)
305+
? declaration.parent.right
306+
: undefined
305307
: undefined;
306308

307309
type NodeCallback = (m: ts.PropertyDeclaration) => boolean;

0 commit comments

Comments
 (0)