Skip to content

Commit 26cc3c4

Browse files
vbfoxljharb
authored andcommitted
[Fix] TSNonNullExpression: Handle function calls
1 parent a0f4f38 commit 26cc3c4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

__tests__/src/getPropValue-babelparser-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,13 @@ describe('getPropValue', () => {
11481148
assert.equal(actual, expected);
11491149
});
11501150

1151+
it('should return string representation of a TSNonNullExpression of form `function()!.property`', () => {
1152+
const prop = extractProp('<div foo={bar()!.bar} />');
1153+
const expected = 'bar()!.bar';
1154+
const actual = getPropValue(prop);
1155+
assert.equal(actual, expected);
1156+
});
1157+
11511158
it('should return string representation of a TSNonNullExpression of form `object!.property!`', () => {
11521159
const prop = extractProp('<div foo={bar!.bar!} />');
11531160
const actual = getPropValue(prop);

src/values/expressions/TSNonNullExpression.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const extractValueFromThisExpression = require('./ThisExpression').default;
2+
const extractValueFromCallExpression = require('./CallExpression').default;
23

34
function navigate(obj, prop, value) {
45
if (value.computed) {
@@ -35,6 +36,10 @@ export default function extractValueFromTSNonNullExpression(value) {
3536
return extractValueFromTSNonNullExpression(value.expression);
3637
}
3738

39+
if (value.type === 'CallExpression') {
40+
return extractValueFromCallExpression(value);
41+
}
42+
3843
if (value.type === 'ThisExpression') {
3944
return extractValueFromThisExpression();
4045
}

0 commit comments

Comments
 (0)