Does Theia only support running with es5 (at least for JSON RPC functionality)?

I was following along https://www.theia-ide.org/doc/Json_Rpc.html to define my own JSON-RPC endpoint but hit an issue, which I believe is due to my transpiling my TS files to ES6 instead of ES5 – I notice that Theia’s own tsconfig targets es5. After targeting es5, I am able to get things working.

The issue is with the way Theia is iterating through the methods to define proxies for them. See https://github.com/theia-ide/theia/blob/master/packages/core/src/common/messaging/proxy-factory.ts#L134

listen(connection: MessageConnection) {
        if (this.target) {
            for (const prop in this.target) {
                if (typeof this.target[prop] === 'function') {
                    connection.onRequest(prop, (...args) => this.onRequest(prop, ...args));
                    connection.onNotification(prop, (...args) => this.onNotification(prop, ...args));
                }
            }
        }
        connection.onDispose(() => this.waitForConnection());
        connection.listen();
        this.connectionPromiseResolve(connection);
    }

When transpiled to ES5, the for…in will get you all the methods of the target.
When transpiled to ES6, the for…in will not get you any of the methods of the target, causing the Unhandled method ${requestMessage.method} to appear when you call it from the front-end.

You can verify this yourself at this simple JSFiddle (be sure to open Developer Tools
) - https://jsfiddle.net/m62cwejv/.

I’m not a ES5 vs ES6 expert, but I believe that this is actually how ES6 enumerability works, based on http://2ality.com/2015/02/es6-classes-final.html#attributes-of-properties

Question: Is this a bug/limitation with Theia? Or does Theia specifically only support ES5? Note I don’t know of all the places where Theia might be doing ES5 specific things but this is at least one that I found.

[original thread by Nick Chen]

for now yes, we’ve tried to migrate to es6 once, but:

  • it produces incompatible code against ts libraries which are compiled for es5, i.e. it cannot extend classes compiled against es5 with generated es6 code

  • ts breaks semantics of some JS functions i.e. Object.keys returns all properties if target is es5 (to be compatible with es3), but only enumerable for es6. We’ve discovered that it adds bugs in Theia code (like for proxies) and its dependencies (inversifyjs).

Because of it compiling different components against different es version will add maintenance overhead for us now.

In some cases it could be possible though, if you limit relationships between es5 and es6 code to functions calls for example.