Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static method #41

Closed
vclteam opened this issue Oct 23, 2014 · 4 comments
Closed

static method #41

vclteam opened this issue Oct 23, 2014 · 4 comments
Labels
question Question about functionality

Comments

@vclteam
Copy link

vclteam commented Oct 23, 2014

dont u think that public static method should appers on other classes?

@sebastian-lenz
Copy link
Member

With other classes you mean subclasses? Something like this:

class A {
    // The static method
    static foo():string { return 'bar'; }
}

class B extends A {
    // Document foo here
}

B.foo();

This is no valid TypeScript as TypeScript does not inherit static methods, the compiler will generate the following error:

The property 'foo' does not exist on value of type 'new() => B'

@sebastian-lenz sebastian-lenz added the question Question about functionality label Oct 26, 2014
@vclteam
Copy link
Author

vclteam commented Oct 26, 2014

as far as i know this is not the case, will check it later but :

https://typescript.codeplex.com/workitem/2047

vcl.js
On Oct 26, 2014 10:30 AM, "Sebastian Lenz" notifications@github.com wrote:

With other classes you mean subclasses? Something like this:

class A {
// The static method
static foo():string { return 'bar'; }}
class B extends A {
// Document foo here}
B.foo();

This is no valid TypeScript as TypeScript does not inherit static methods,
the compiler will generate the following error:

The property 'foo' does not exist on value of type 'new() => B'


Reply to this email directly or view it on GitHub
#41 (comment)
.

@jvilk
Copy link

jvilk commented Feb 19, 2015

@vclteam is right, and I had no idea this was the case! True for methods and fields. Nasty.

class A {
    // The static method
    static foo():string { return 'bar'; }
    static bar: string = "foo";
}

class B extends A {
    // Document foo here
}

console.log(B.foo());
console.log(B.bar);

Compiling/running (TS 1.4):

$ tsc test.ts
$ node test.js
bar
foo

And this means that B has a separate, implicitly inherited bar field from A.

@sebastian-lenz
Copy link
Member

Actually TypeDoc behaves like this since v.0.2, static fields and methods are now inherited and I've also added the corresponding icons.

lddubeau pushed a commit to lddubeau/typedoc that referenced this issue Apr 5, 2018
* Adds guard against empty `model.readme`
* Use correct name for `flags` array

This patch ensures the flags are made visible, flags such as `static` and `optional` were not appearing.

* Style changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about functionality
Projects
None yet
Development

No branches or pull requests

3 participants