This project is read-only.

call empty function in class

Topics: General
May 10, 2013 at 4:46 PM
You can write following:
declare class A {
But you cannot call this function:
var x = new A();
Value of 'A' is not callable.

How the function can be called ?
If it cannot be called why this is allowed ?
May 10, 2013 at 5:36 PM
The declare keyword is used to describe existing objects. If you try to describing an existing object that doesn't actually exist, you will get an error.

If you want to write an actual class, don't use declare:
class A {
    public fn() { }
May 10, 2013 at 6:19 PM
You don't really need existing object.
This is valid code:
declare class A {

var x = new A();
The question is what "function():any" means in declared class and why it is allowed.
May 10, 2013 at 8:46 PM
Sorry, I misinterpreted the post. What this does is create a function called 'function':
declare class A {

var x: A;
May 10, 2013 at 8:48 PM
Ah.. right :)