@@ -28,7 +28,7 @@ import {
2828} from "typescript" ;
2929
3030import { IExternCallbackParameterDescriptor , IExternFileDescriptor } from "#/parse/utils/types" ;
31- import { Optional } from "#/utils/types" ;
31+ import { AnyObject , Optional } from "#/utils/types" ;
3232
3333/**
3434 * Method name used for externals declaration.
@@ -46,7 +46,7 @@ export function getExternDocs(files: Array<string>): Array<IExternFileDescriptor
4646 . filter ( ( it : Statement ) => {
4747 if ( ! isExpressionStatement ( it ) ) {
4848 return false ;
49- } else if ( it . expression ?. [ "expression" ] ?. escapedText !== EXTERN_METHOD_NAME ) {
49+ } else if ( ( it . expression as AnyObject ) ?. [ "expression" ] ?. escapedText !== EXTERN_METHOD_NAME ) {
5050 return false ;
5151 }
5252
@@ -64,10 +64,10 @@ export function getExternDocs(files: Array<string>): Array<IExternFileDescriptor
6464 } )
6565 . map ( ( statement : Statement ) => {
6666 const callExpression : CallExpression = ( statement as ExpressionStatement ) . expression as CallExpression ;
67- const doc : Optional < JSDoc > = statement [ "jsDoc" ] && statement [ "jsDoc" ] [ 0 ] ;
67+ const doc : Optional < JSDoc > = ( statement as AnyObject ) [ "jsDoc" ] && ( statement as AnyObject ) [ "jsDoc" ] [ 0 ] ;
6868 const externCallback : ArrowFunction = callExpression . arguments [ 1 ] as ArrowFunction ;
6969
70- const externName : string = callExpression . arguments [ 0 ] [ "text" ] ;
70+ const externName : string = ( callExpression . arguments [ 0 ] as AnyObject ) [ "text" ] ;
7171 let docComment : string = doc ? ( doc . comment as string ) : "" ;
7272 let callbackDescription : Array < IExternCallbackParameterDescriptor > = [ ] ;
7373
@@ -77,7 +77,9 @@ export function getExternDocs(files: Array<string>): Array<IExternFileDescriptor
7777 doc . tags
7878 . map ( ( it : JSDocTag ) : string => {
7979 const tagName : string = it . tagName . escapedText as string ;
80- const itemName = it [ "name" ] ? it [ "name" ] . escapedText : null ;
80+ const itemName : Optional < string > = ( it as AnyObject ) [ "name" ]
81+ ? ( it as AnyObject ) [ "name" ] . escapedText
82+ : null ;
8183
8284 return `[${ tagName } ] ${ itemName ? itemName + " " : "" } ${ ( it . comment as string ) || "" } ` ;
8385 } )
@@ -151,28 +153,28 @@ function getNodeTypeLabel(node: TypeNode | NullLiteral): string {
151153 * Get parameter label for provided AST node.
152154 */
153155function getNodeName ( node : NamedDeclaration ) : string {
154- if ( ( node . name . kind as SyntaxKind ) === SyntaxKind . ArrayBindingPattern ) {
156+ if ( ( node . name ? .kind as SyntaxKind ) === SyntaxKind . ArrayBindingPattern ) {
155157 return `[${ ( node . name as unknown as ArrayBindingPattern ) . elements
156158 . map ( ( it ) => getNodeName ( it as unknown as ParameterDeclaration ) )
157159 . join ( ", " ) } ]`;
158160 } else {
159- return node . name [ "escapedText" ] as string ;
161+ return ( node . name as AnyObject ) ?. [ "escapedText" ] as string ;
160162 }
161163}
162164
163165/**
164166 * Get descriptor of callback parameter AST node.
165167 */
166168function getCallbackParameterDescriptor ( parameter : ParameterDeclaration ) : IExternCallbackParameterDescriptor {
167- switch ( parameter . type . kind ) {
169+ switch ( parameter . type ? .kind ) {
168170 case SyntaxKind . NumberKeyword :
169171 case SyntaxKind . StringKeyword :
170172 case SyntaxKind . BooleanKeyword :
171173 case SyntaxKind . NullKeyword :
172174 case SyntaxKind . TupleType :
173175 return {
174176 parameterName : getNodeName ( parameter ) ,
175- parameterTypeName : getNodeTypeLabel ( parameter . type ) ,
177+ parameterTypeName : getNodeTypeLabel ( parameter . type as TypeNode ) ,
176178 } ;
177179
178180 default :
0 commit comments