GithubHelp home page GithubHelp logo

balupton / es6-javascript-class-interop Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 2.0 8 KB

Do ES6 classes classes play nicely with ES5 and CoffeeScript Classes?

CoffeeScript 14.95% JavaScript 69.16% Erlang 15.89%
proof-of-concept

es6-javascript-class-interop's Introduction

JavaScript and CoffeeScript Classes Interoperability

Get the results

  1. clone the repo
  2. npm install
  3. npm test

What do the results say?

  • ES6 classes can extend ES5 and CoffeeScript classes
  • CoffeeScript can extend ES5 classes, but CoffeeScript cannot extend ES6 classes
  • ES5 can extend CoffeeScript classes, but ES5 cannot extend ES6 classes
classes interop
classes interop ➞  es5 extending es5
classes interop ➞  es5 extending es5 ✔
classes interop ➞  es5 extending es6
classes interop ➞  es5 extending es6 ✘
classes interop ➞  es5 extending coffee
classes interop ➞  es5 extending coffee ✔
classes interop ➞  es6 extending es5
classes interop ➞  es6 extending es5 ✔
classes interop ➞  es6 extending es6
classes interop ➞  es6 extending es6 ✔
classes interop ➞  es6 extending coffee
classes interop ➞  es6 extending coffee ✔
classes interop ➞  coffee extending es5
classes interop ➞  coffee extending es5 ✔
classes interop ➞  coffee extending es6
classes interop ➞  coffee extending es6 ✘
classes interop ➞  coffee extending coffee
classes interop ➞  coffee extending coffee ✔
classes interop ✔

FAILURE: 7/9 tests ran successfully; 2 failed, 0 incomplete, 2 errors

Error #1:
classes interop ➞  es5 extending es6
TypeError: Class constructors cannot be invoked without 'new'
    at new BaseClass (class.es:3:3)
    at BaseClass.NewClass (extends.js:3:16)
    at check (test.js:8:12)
    at EventEmitterGrouped.<anonymous> (test.js:38:5)
    at ambi (/Users/balupton/Projects/active/classes-coffeescript-vs-javascript/node_modules/ambi/out/lib/ambi.js:57:27)
    at Domain.fireMethod (/Users/balupton/Projects/active/classes-coffeescript-vs-javascript/node_modules/taskgroup/out/lib/taskgroup.js:385:23)
    at Domain.run (domain.js:228:14)
    at EventEmitterGrouped.Task.fire (/Users/balupton/Projects/active/classes-coffeescript-vs-javascript/node_modules/taskgroup/out/lib/taskgroup.js:423:27)
    at Immediate._onImmediate (/Users/balupton/Projects/active/classes-coffeescript-vs-javascript/node_modules/taskgroup/out/lib/taskgroup.js:440:26)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

Error #2:
classes interop ➞  coffee extending es6
TypeError: Class constructors cannot be invoked without 'new'
    at NewClass.BaseClass (class.es:3:3)
    at new NewClass (/Users/balupton/Projects/active/classes-coffeescript-vs-javascript/extends.coffee:11:40)
    at check (test.js:8:12)
    at EventEmitterGrouped.<anonymous> (test.js:38:5)
    at ambi (/Users/balupton/Projects/active/classes-coffeescript-vs-javascript/node_modules/ambi/out/lib/ambi.js:57:27)
    at Domain.fireMethod (/Users/balupton/Projects/active/classes-coffeescript-vs-javascript/node_modules/taskgroup/out/lib/taskgroup.js:385:23)
    at Domain.run (domain.js:228:14)
    at EventEmitterGrouped.Task.fire (/Users/balupton/Projects/active/classes-coffeescript-vs-javascript/node_modules/taskgroup/out/lib/taskgroup.js:423:27)
    at Immediate._onImmediate (/Users/balupton/Projects/active/classes-coffeescript-vs-javascript/node_modules/taskgroup/out/lib/taskgroup.js:440:26)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

npm ERR! Test failed.  See above for more details.

es6-javascript-class-interop's People

Contributors

balupton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

es6-javascript-class-interop's Issues

Cannot run tests

I‘m trying to get this to run. Under Node 7.1.0, after npm install when I run npm test I get:

classes interop
classes interop ✘

FAILURE: 0/0 tests ran successfully; 0 failed, 0 incomplete, 1 errors

Error #1:
classes interop
Error: Deprecated configuration property [onError] given to TaskGroup::setConfig()

If I lock the version numbers of your dependencies in package.json (i.e. removing all the ^s) and run under Node 4.6.2, which is what I presume you were using back in February, I get this:

/Volumes/Geoffrey/Sites/es6-javascript-class-interop/class.es:2
	return class BaseClass {
	       ^^^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

With Node 7.1.0 and fixed versions of packages, I get this:

/Volumes/Geoffrey/Sites/es6-javascript-class-interop/node_modules/joe/out/lib/joe.js:186
        this.emitSerial('before', (function(_this) {
             ^

TypeError: this.emitSerial is not a function

and with the latest versions of packages (via npm-check-updates):

joe has no reporters to log: startSuite EventEmitterGrouped {
  domain: null,
  _events:
   { error: [Function: bound listener],
     completed: [Function: bound listener],
     'item.add': [Function],
     running: [Function],
     done: [ [Object], [Object] ],
     before: [Function],
     after: [Function] },
  _eventsCount: 7,
  _maxListeners: undefined,
  state:
   { result: [],
     error: null,
     status: 'running',
     itemsRemaining: [ [Object] ],
     itemsExecutingCount: 0,
     itemsDoneCount: 0 },
  config:
   { nameSeparator: ' ➞  ',
     storeResult: null,
     destroyOnceDone: true,
     parent:
      EventEmitterGrouped {
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        state: [Object],
        config: [Object] },
     method: [Function],
     abortOnError: true,
     destroyDoneItems: true,
     nestedTaskConfig: {},
     nestedTaskGroupConfig: {},
     emitNestedEvents: false,
     concurrency: 1,
     run: null,
     name: 'classes interop' } }
joe has no reporters to log: exit 1 undefined
npm ERR! Test failed.  See above for more details.

Can you still run this today? Do you mind please updating the package.json with the specific version of Node, and specific versions of packages, that work for you?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.