|
15 | 15 |
|
16 | 16 | import { parse } from '@babel/parser' |
17 | 17 | import type { Expression, Node, ObjectExpression, PatternLike } from '@babel/types' |
18 | | -import { childNodes, memberName } from '../babel' |
| 18 | +import { childNodes, isMemberAccess, memberName } from '../babel' |
19 | 19 | import { parseStoredPath } from '../code-files/ref-path' |
20 | 20 | import { toCodeFile } from '../code-files/to-file' |
21 | 21 | import type { BlockKey, CanonicalBlock } from '../model' |
@@ -295,8 +295,9 @@ class Inference { |
295 | 295 | if (BOOLEAN_FUNCTIONS.has(callee.name)) return 'boolean' |
296 | 296 | return undefined |
297 | 297 | } |
| 298 | + if (!isMemberAccess(callee)) return undefined |
298 | 299 | const method = memberName(callee) |
299 | | - if (method === null || !('object' in callee)) return undefined |
| 300 | + if (method === null) return undefined |
300 | 301 | if (callee.object.type === 'Identifier') { |
301 | 302 | if (callee.object.name === 'Math') return this.isBuiltin('Math') ? 'number' : undefined |
302 | 303 | const known = STATIC_KINDS[`${callee.object.name}.${method}`] |
@@ -356,8 +357,9 @@ class Inference { |
356 | 357 | private isArray(node: Node, strict = false): boolean { |
357 | 358 | if (node.type === 'ArrayExpression') return true |
358 | 359 | if (node.type === 'CallExpression' || node.type === 'OptionalCallExpression') { |
| 360 | + if (!isMemberAccess(node.callee)) return false |
359 | 361 | const method = memberName(node.callee) |
360 | | - if (method === null || !('object' in node.callee)) return false |
| 362 | + if (method === null) return false |
361 | 363 | if (node.callee.object.type === 'Identifier' && node.callee.object.name === 'Object') { |
362 | 364 | return ( |
363 | 365 | this.isBuiltin('Object') && |
|
0 commit comments