@@ -34,16 +34,19 @@ function format(prop: MethodSignature | PropertySignature | PropertyAssignment):
3434 name : prop . getName ( ) ,
3535 type : prop . getType ( ) . getText ( prop ) ,
3636 optional : prop . hasQuestionToken ( ) || false ,
37- description : ( prop as PropertySignature ) . getJsDocs ? (
38- ( prop as PropertySignature ) . getJsDocs ( ) [ 0 ] && ( prop as PropertySignature ) . getJsDocs ( ) [ 0 ] . getComment ( )
39- ) : (
40- ( prop as PropertyAssignment ) . getInitializerIfKind ( SyntaxKind . StringLiteral ) &&
41- ( prop as PropertyAssignment ) . getInitializerIfKind ( SyntaxKind . StringLiteral ) ! . getLiteralValue ( )
42- )
37+ description : ( prop as PropertySignature ) . getJsDocs
38+ ? ( prop as PropertySignature ) . getJsDocs ( ) [ 0 ] &&
39+ ( prop as PropertySignature ) . getJsDocs ( ) [ 0 ] . getComment ( )
40+ : ( prop as PropertyAssignment ) . getInitializerIfKind ( SyntaxKind . StringLiteral ) &&
41+ ( prop as PropertyAssignment )
42+ . getInitializerIfKind ( SyntaxKind . StringLiteral ) !
43+ . getLiteralValue ( )
4344 } ;
4445}
4546
46- function isSignatureOrAssignment ( node : any ) : node is MethodSignature | PropertySignature | PropertyAssignment {
47+ function isSignatureOrAssignment (
48+ node : any
49+ ) : node is MethodSignature | PropertySignature | PropertyAssignment {
4750 return Boolean ( node && node . getName && node . getType && node . hasQuestionToken ) ;
4851}
4952
@@ -80,27 +83,33 @@ function getTypeFromFactory(factory: CallExpression, children = false) {
8083
8184function parseI18n ( node : CallExpression ) {
8285 const propertyAccess = node . getChildAtIndex ( 0 ) ;
83- const functionSymbol = propertyAccess &&
86+ const functionSymbol =
87+ propertyAccess &&
8488 propertyAccess . getKind ( ) === SyntaxKind . PropertyAccessExpression &&
8589 propertyAccess . getSymbol ( ) ;
8690 const functionType = functionSymbol && functionSymbol . getTypeAtLocation ( node ) ;
8791 const callType = functionType && functionType . getCallSignatures ( ) [ 0 ] ;
88- const argument = callType && callType . getParameters ( ) [ 0 ]
92+ const argument = callType && callType . getParameters ( ) [ 0 ] ;
8993 const parameterType = argument && argument . getTypeAtLocation ( node ) ;
9094 const parameterSymbol = parameterType && parameterType . getSymbol ( ) ;
9195 const parameterSymbolName = parameterSymbol && parameterSymbol . getName ( ) ;
9296 const returnType = callType && callType . getReturnType ( ) ;
9397 const returnAliasSymbol = returnType && returnType . getAliasSymbol ( ) ;
9498 const returnAliasName = returnAliasSymbol && returnAliasSymbol . getName ( ) ;
95- if ( parameterType && parameterSymbolName === 'Bundle' && returnAliasName === 'LocalizedMessages' ) {
96- const argument = node . getArguments ( ) [ 0 ]
99+ if (
100+ parameterType &&
101+ parameterSymbolName === 'Bundle' &&
102+ returnAliasName === 'LocalizedMessages'
103+ ) {
104+ const argument = node . getArguments ( ) [ 0 ] ;
97105 const argumentType = argument && argument . getType ( ) ;
98106 const messages = argumentType && argumentType . getProperty ( 'messages' ) ;
99107 const locales = argumentType && argumentType . getProperty ( 'locales' ) ;
100108 const messageProps = messages && messages . getTypeAtLocation ( node ) ;
101109 const localeProps = locales && locales . getTypeAtLocation ( node ) ;
102110 return {
103- messages : messageProps && getPropertyDetails ( messageProps ) , locales : localeProps && getPropertyDetails ( localeProps )
111+ messages : messageProps && getPropertyDetails ( messageProps ) ,
112+ locales : localeProps && getPropertyDetails ( localeProps )
104113 } ;
105114 }
106115
@@ -164,7 +173,8 @@ export default function(config: { [index: string]: string }) {
164173
165174 if ( typeArguments . length ) {
166175 const widgetSymbol = typeArguments [ 0 ] . getChildAtIndex ( 0 ) . getSymbol ( ) ;
167- const widgetChildrenSymbol = typeArguments [ 1 ] && typeArguments [ 1 ] . getChildAtIndex ( 0 ) . getSymbol ( ) ;
176+ const widgetChildrenSymbol =
177+ typeArguments [ 1 ] && typeArguments [ 1 ] . getChildAtIndex ( 0 ) . getSymbol ( ) ;
168178
169179 if ( widgetSymbol ) {
170180 propsType = widgetSymbol . getDeclaredType ( ) ;
@@ -179,19 +189,19 @@ export default function(config: { [index: string]: string }) {
179189 } else if ( node . getKind ( ) === SyntaxKind . ExportAssignment ) {
180190 initializer = ( node as ExportAssignment ) . getExpression ( ) ;
181191 } else if ( node . getKind ( ) === SyntaxKind . CallExpression ) {
182- const parsedI18n = parseI18n ( node as CallExpression )
192+ const parsedI18n = parseI18n ( node as CallExpression ) ;
183193 if ( parsedI18n . messages ) {
184194 messages . push ( ...parsedI18n . messages ) ;
185195 }
186196
187- if ( parsedI18n . locales ) {
197+ if ( parsedI18n . locales ) {
188198 locales = parsedI18n . locales ;
189199 }
190200 }
191201
192202 if ( initializer && initializer . getKind ( ) === SyntaxKind . CallExpression ) {
193203 propsType = getTypeFromFactory ( initializer ) ;
194- childrenType = getTypeFromFactory ( initializer , true ) ;
204+ childrenType = getTypeFromFactory ( initializer , true ) ;
195205 }
196206 } ) ;
197207
@@ -247,30 +257,35 @@ export default function(config: { [index: string]: string }) {
247257 if ( unionTypes && unionTypes . length ) {
248258 unionTypes . forEach ( ( unionType ) => {
249259 const unionProperties = getPropertyDetails ( unionType ) ;
250- unionProperties . forEach ( type => parseUnionType ( type , properties ) ) ;
260+ unionProperties . forEach ( ( type ) => parseUnionType ( type , properties ) ) ;
251261 } ) ;
252262 }
253263 childUnionTypes . forEach ( ( unionType ) => {
254264 const text = unionType . getText ( undefined , TypeFormatFlags . None ) ;
255- if ( unionType . isArray ( ) || ! unionType . isObject ( ) || (
256- text && ( text . startsWith ( 'WNode' ) || text . startsWith ( 'VNode' ) || text . startsWith ( 'DNode' ) )
257- ) ) {
265+ if (
266+ unionType . isArray ( ) ||
267+ ! unionType . isObject ( ) ||
268+ ( text &&
269+ ( text . startsWith ( 'WNode' ) ||
270+ text . startsWith ( 'VNode' ) ||
271+ text . startsWith ( 'DNode' ) ) )
272+ ) {
258273 children . push ( {
259274 name : '----' ,
260275 type : text ,
261276 optional : false
262277 } ) ;
263278 } else {
264279 const callSignatures = unionType . getCallSignatures ( ) ;
265- callSignatures . forEach ( signature => {
280+ callSignatures . forEach ( ( signature ) => {
266281 children . push ( {
267282 name : '----' ,
268283 type : signature . getDeclaration ( ) . getFullText ( ) ,
269284 optional : false
270285 } ) ;
271286 } ) ;
272287 const unionProperties = getPropertyDetails ( unionType ) ;
273- unionProperties . forEach ( type => parseUnionType ( type , children ) ) ;
288+ unionProperties . forEach ( ( type ) => parseUnionType ( type , children ) ) ;
274289 }
275290 } ) ;
276291
0 commit comments