microsoft / TypeScript-Handbook

Deprecated, please use the TypeScript-Website repo instead
https://github.com/microsoft/TypeScript-Website
Apache License 2.0
4.88k stars 1.13k forks source link

Documented applyMixins doesn't compile since TypeScript 2.7 #1296

Open fer22f opened 4 years ago

fer22f commented 4 years ago

The following snippet from the handbook doesn't compile anymore:

function applyMixins(derivedCtor: any, baseCtors: any[]) {
    baseCtors.forEach(baseCtor => {
        Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
            Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name));
        });
    });
}

2.7.2 Playground 2.4.1 Playground

Any suggestions on how to fix it?

Akazm commented 4 years ago

Bump