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

__extend() failed to copy static getters #1868

Closed
qc00 opened this issue Jan 30, 2015 · 3 comments
Closed

__extend() failed to copy static getters #1868

qc00 opened this issue Jan 30, 2015 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@qc00
Copy link

qc00 commented Jan 30, 2015

__extends() currently use the normal property access syntax to copy static properties which means it will copy the result of the getter to the sub-class instead of the getter itself.

It should do something like this if ES5 is supported:

var FUN_PROTO_NAMES = Object.getOwnPropertyNames(Function);

export function copyStatic(from: Function, to: Function) {
    Object.getOwnPropertyNames(from).forEach(p => {
        if (FUN_PROTO_NAMES.indexOf(p) === -1) {
            Object.defineProperty(to, p, Object.getOwnPropertyDescriptor(from, p));
        }
    });
}
@danquirk
Copy link
Member

This has been an issue for a long time: http://typescript.codeplex.com/workitem/2324

I'm not sure our reasoning has changed since then.

@yortus
Copy link
Contributor

yortus commented Jan 31, 2015

Also discussed more recently here: #1520

@danquirk danquirk added the Duplicate An existing issue was already created label Jan 31, 2015
@danquirk
Copy link
Member

Thanks, don't know why I couldn't find that.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants