Giter Club home page Giter Club logo

Comments (5)

mprobst avatar mprobst commented on July 19, 2024

+1 on not emitting call/apply for ctors, AFAIK it's even illegal to use
apply on an ES6 class, so this is bound to only cause confusion.

Rado Kirov [email protected] schrieb am Mi., 2. Sep. 2015 um
02:47 Uhr:

For example if B extends A and takes string instead of number, we generate:

declare namespace f {
class A {
constructor(n: number);
static call(a: A, n: number);
}

class B extends A {
    constructor(s: string);
    static call(b: B, n: string);
}

}

TS barfs on the static call for B which is required to subtype A's
functional type. See 'oog.fx.dom.PredefinedEffect' and 'Animation' for
closure lib repro.

Maybe we should not output call and apply for constructor functions until
someone really needs them. I can't come up with a good need for using those
in sane TS code.


Reply to this email directly or view it on GitHub
#76.

from clutz.

rkirov avatar rkirov commented on July 19, 2024

Turns out these static methods are only output if they are used somewhere else (most likely for implementing super constructor calls).

from clutz.

rkirov avatar rkirov commented on July 19, 2024

I can't get the following Closure code to compile in our test harness:

/**
 * @constructor
 * @param {number} n
 */
multi_class.A = function(n) {
  /** @type {number} */
  this.a = n;
};

/**
 * @constructor
 * @extends {multi_class.A}
 */
multi_class.B = function() {
  /** @type {number} */
  this.b = 1;
  multi_class.A.call(this, 0);
};
goog.inherits(multi_class.B, multi_class.A);

with error java.lang.AssertionError: JSC_UNDEFINED_NAME. multi_class.A.call is never defined at test.js line 21 : 2

Closure complains that it can't find call on multi_class.A, even though that's the pattern that goog.fx.dom.PredefinedEffect and subclasses use.

Works fine in the standalone cl compiler which probably means we are have some different flag setting.

from clutz.

rkirov avatar rkirov commented on July 19, 2024

cc @MatrixFrog

from clutz.

MatrixFrog avatar MatrixFrog commented on July 19, 2024

I think it would still be good to know why the type system works this way, but I suspect the new type system is a little more sane so I'm not overly worried about it.

from clutz.

Related Issues (20)

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.