File tree 1 file changed +13
-13
lines changed
1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -253,11 +253,7 @@ export function parseFromProgram(filePath: string, program: ts.Program) {
253
253
return t . undefinedNode ( ) ;
254
254
}
255
255
256
- if ( type . flags & ts . TypeFlags . Object ) {
257
- return type . getCallSignatures ( ) . length === 0 ? t . objectNode ( ) : t . functionNode ( ) ;
258
- }
259
-
260
- if ( type . flags & ts . TypeFlags . Any ) {
256
+ if ( type . flags & ts . TypeFlags . Any || type . flags & ts . TypeFlags . Unknown ) {
261
257
return t . anyNode ( ) ;
262
258
}
263
259
@@ -271,21 +267,25 @@ export function parseFromProgram(filePath: string, program: ts.Program) {
271
267
return t . literalNode ( checker . typeToString ( type ) ) ;
272
268
}
273
269
274
- if ( type . flags & ts . TypeFlags . NonPrimitive && checker . typeToString ( type ) === 'object' ) {
275
- return t . objectNode ( ) ;
276
- }
277
-
278
270
if ( type . flags & ts . TypeFlags . Null ) {
279
271
return t . literalNode ( 'null' ) ;
280
272
}
281
273
282
- // {foo: string} & {bar: string}
283
- if ( type . isIntersection ( ) ) {
274
+ if ( type . getCallSignatures ( ) . length ) {
275
+ return t . functionNode ( ) ;
276
+ }
277
+
278
+ // Object-like type
279
+ if ( type . getProperties ( ) . length ) {
284
280
return t . objectNode ( ) ;
285
281
}
286
282
287
- if ( type . flags & ts . TypeFlags . Unknown ) {
288
- return t . anyNode ( ) ;
283
+ // Object without properties or object keyword
284
+ if (
285
+ type . flags & ts . TypeFlags . Object ||
286
+ ( type . flags & ts . TypeFlags . NonPrimitive && checker . typeToString ( type ) === 'object' )
287
+ ) {
288
+ return t . objectNode ( ) ;
289
289
}
290
290
291
291
console . warn (
You can’t perform that action at this time.
0 commit comments