Undefind as an arg over plugin JSON RPC

undefined values get converted to null, when they are passed over plugin JSON RPC, since Theia APIs don’t expect null it can lead to troubles. I found a bug in a case with preference service, it tries to compute optional resource URI for the workspace scope, but since null does not count as optional arg it does not compute, leading to bogus behaviour.

[original thread by Anton Kosyakov]

@florentbenoit @yevhen i wonder can we do something about it? should we use null explicitly instead of optional args for plugin APIs? or serialize args differently to preserve undefined values

it boils down to JSON.stringify([null]) === JSON.stringify([undefined])

@anton-kosyakov should we encode undefined like we encode URI when serializing ? (it’s handled only by RPC protocol then ?)

it will increase amount of data which we need to send over.

Also it seems to affect only array values, let me check

let’s replace null with undefined for array during diserialization? Could be there cases when somone pass null on purporse? We don’t allow null as a value in Theia repo.

vscode extensions can provide null or not on your use-case ? because they have their own tsconfig rules
or it’s only related to the internal classes of plugin-ext ?

only to plugin-api.ts

so yes

and probably only to funtction args

at least it should fix my current issues