1

When running Sencha Cmd v6.5.3.6, i get the following error message:

[ERR] C2001: Closure Compiler Error (This code cannot be converted from ES6. extending native class: Array) -- compression-input:111263

The error is caused by this code:

class Chains extends Array {
}

The error still occurs with methods inside class declaration.

Is there a way to make this code compiled by Sencha Cmd ?

UPDATED : To solve the problem, I change the code to:

function Chains() { };
Chains.prototype = new Array;
Chains.prototype.anyMethod = function () { }

2 Answers 2

2

You are using a feature of ES6 that cannot be transpiled into pre-ES6 code.

Sencha Cmd by default transpiles your code into pre-ES6 code because IE11 support has not yet been dropped.

You can disable code transpilation starting with Sencha Cmd 6.5.0 as described in the official docs:

There are cases where you won't need all that transpiling. Maybe you’re targeting Electron or you only support modern browsers that have all these features. You can disable the transpiler and still use the Sencha Cmd code compressor against your native ES6 code. Just a tweak to the app.json file and say goodbye to the transpiler and its polyfills:

"output": {
    "js": {
        "version": "ES6"
    }
}
Sign up to request clarification or add additional context in comments.

Comments

1

I don't think ExtJS supports that syntax as of now. For the time being, you might have to go with their syntax:

Ext.define('Chains', {
    extend: 'Array'
});

Then in your code you can call it like this:

var chns = Ext.create('Chains');
chns.push('a');
console.log(chns);

4 Comments

It compile now without error, but the Chains is no more an array. It is no more possible to call the "push" method on a Chains object, which is the behavior I need.
My bad, I was using "extends" instead of "extend". It works fine now. Thank you.
Sencha cmd display now this error message :"[ERR] Failed to resolve dependency Array for file Link.Chains [ERR] Unknown definition for dependency : Array"
So i'm going to use an array extension, involving prototype, and with a new class name, as described here : stackoverflow.com/questions/11337849/… But not the solution involving ES6 language version, no: class a extends b { }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.