Skip to content

Commit b7447a2

Browse files
committed
feature: @putout/plugin-types: convert-typeof-to-is-type: CallExpression
1 parent cc544d4 commit b7447a2

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
isUndefined(a());
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a() === undefined

packages/plugin-types/lib/convert-typeof-to-is-type/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {operator} from 'putout';
1+
import {operator, types} from 'putout';
2+
3+
const {isCallExpression} = types;
24

35
const {
46
compare,
@@ -97,6 +99,9 @@ function check({__a, __b}, path) {
9799
if (__b && isBind(path, extract(__b)))
98100
return false;
99101

102+
if (isCallExpression(__a))
103+
return true;
104+
100105
return getBindingPath(path, __a);
101106
}
102107

packages/plugin-types/lib/convert-typeof-to-is-type/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ test('plugin-convert-typeof-to-is-type: no transform: not-declared', (t) => {
8383
t.end();
8484
});
8585

86+
test('plugin-convert-typeof-to-is-type: transform: call', (t) => {
87+
t.transform('call');
88+
t.end();
89+
});
90+
8691
test('plugin-convert-typeof-to-is-type: no report: declare-before-reference', (t) => {
8792
t.noReport('declare-before-reference', [
8893
['declare-before-reference', declareBeforeReference],

0 commit comments

Comments
 (0)