# Expected an assignment or function call and instead saw an expression for "myvar?.myfunction()

**URL:** <https://community.sonarsource.com/t/expected-an-assignment-or-function-call-and-instead-saw-an-expression-for-myvar-myfunction/21655>\
**Category:** SonarQube Cloud\
**Tags:** typescript\
**Created:** [March 16, 2020, 7:34am UTC](https://community.sonarsource.com/t/expected-an-assignment-or-function-call-and-instead-saw-an-expression-for-myvar-myfunction/21655 "2020-03-16T07:34:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apupier](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/apupier/32/128_2.png) [@apupier](https://community.sonarsource.com/u/apupier)\
**Post date:** [March 16, 2020, 7:34am UTC](https://community.sonarsource.com/t/expected-an-assignment-or-function-call-and-instead-saw-an-expression-for-myvar-myfunction/21655/1 "2020-03-16T07:34:54Z")

</div>

Template for a good false-positive report, formatted with [Markdown](https://commonmark.org/help/):

- versions used  
using [sonarcloud.io](http://sonarcloud.io)
- minimal code sample to reproduce (with analysis parameter, and potential instructions to compile).  
see [https://sonarcloud.io/project/issues?id=vscode-camelk&issues=AW\_20fPg15CiwQ6EBWS1&open=AW\_20fPg15CiwQ6EBWS1](https://sonarcloud.io/project/issues?id=vscode-camelk&issues=AW_20fPg15CiwQ6EBWS1&open=AW_20fPg15CiwQ6EBWS1)  
see [https://github.com/camel-tooling/vscode-camelk/blob/41c8d52b6195979d903d07b4e35504d1e12ad4fc/src/extension.ts#L315](https://github.com/camel-tooling/vscode-camelk/blob/41c8d52b6195979d903d07b4e35504d1e12ad4fc/src/extension.ts#L315)

````auto
	camelKIntegrationsTreeView = vscode.window.createTreeView('camelk.integrations', {
		treeDataProvider: camelKIntegrationsProvider
	});
	camelKIntegrationsTreeView.onDidChangeVisibility(async () => {
		if (camelKIntegrationsTreeView.visible === true) {
			if (runningKubectl === undefined || runningKubectl.killed) {
				eventEmitter.emit(restartKubectlWatchEvent);
			}
			await camelKIntegrationsProvider.refresh().catch(err => console.log(err));
		} else {
			runningKubectl?.kill(); <--- error here, runningKubectl is of type ChildProcess from child_process
		}
	});
}```
````

---

<div class="post-metadata">

**Author:** ![Quentin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/quentin/32/74716_2.png) [@Quentin](https://community.sonarsource.com/u/Quentin)\
**Post date:** [March 16, 2020, 8:17am UTC](https://community.sonarsource.com/t/expected-an-assignment-or-function-call-and-instead-saw-an-expression-for-myvar-myfunction/21655/2 "2020-03-16T08:17:54Z")

</div>

Hello @apupier,

I believe you are facing the same issue as reported here:

> [@Optional chaining in Typescript is reported as an expression](https://community.sonarsource.com/t/optional-chaining-in-typescript-is-reported-as-an-expression/21265):
>
> versions used (SonarQube, Scanner, Plugin, and any relevant extension): cloud error observed: export default class Vimeo extends React.Component\<Props\> { constructor(p: Props) { super(p) this.player = null } private player: Player | null componentWillUnmount() { this.player?.destroy() // =\> Expected an assignment or function call and instead saw an expression. Bug, Major, 10min effort } // etc... } steps to reproduce: above code I think your linter doesn’t support “opt…

Feel free to come back to us if you face another issue.

Best,  
Quentin

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [April 8, 2021, 9:09am UTC](https://community.sonarsource.com/t/expected-an-assignment-or-function-call-and-instead-saw-an-expression-for-myvar-myfunction/21655/3 "2021-04-08T09:09:55Z")

</div>

Closed on April 8, 2021, 9:09am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
