|
| 1 | +//// [tests/cases/conformance/classes/mixinWithUnknownRestParam.ts] //// |
| 2 | + |
| 3 | +=== mixinWithUnknownRestParam.ts === |
| 4 | +// Repro for https://github.com/microsoft/TypeScript/issues/29707 |
| 5 | +// unknown[] should be a valid mixin constructor constraint, same as any[] |
| 6 | + |
| 7 | +type ClassConstructor = new (...args: unknown[]) => {} |
| 8 | +>ClassConstructor : Symbol(ClassConstructor, Decl(mixinWithUnknownRestParam.ts, 0, 0)) |
| 9 | +>args : Symbol(args, Decl(mixinWithUnknownRestParam.ts, 3, 29)) |
| 10 | + |
| 11 | +function mixin<C extends ClassConstructor>(Class: C) { |
| 12 | +>mixin : Symbol(mixin, Decl(mixinWithUnknownRestParam.ts, 3, 54)) |
| 13 | +>C : Symbol(C, Decl(mixinWithUnknownRestParam.ts, 5, 15)) |
| 14 | +>ClassConstructor : Symbol(ClassConstructor, Decl(mixinWithUnknownRestParam.ts, 0, 0)) |
| 15 | +>Class : Symbol(Class, Decl(mixinWithUnknownRestParam.ts, 5, 43)) |
| 16 | +>C : Symbol(C, Decl(mixinWithUnknownRestParam.ts, 5, 15)) |
| 17 | + |
| 18 | + return class extends Class {} |
| 19 | +>Class : Symbol(Class, Decl(mixinWithUnknownRestParam.ts, 5, 43)) |
| 20 | +} |
| 21 | + |
| 22 | +class Base { |
| 23 | +>Base : Symbol(Base, Decl(mixinWithUnknownRestParam.ts, 7, 1)) |
| 24 | + |
| 25 | + constructor(public x: number) {} |
| 26 | +>x : Symbol(Base.x, Decl(mixinWithUnknownRestParam.ts, 10, 16)) |
| 27 | +} |
| 28 | + |
| 29 | +const Mixed = mixin(Base) |
| 30 | +>Mixed : Symbol(Mixed, Decl(mixinWithUnknownRestParam.ts, 13, 5)) |
| 31 | +>mixin : Symbol(mixin, Decl(mixinWithUnknownRestParam.ts, 3, 54)) |
| 32 | +>Base : Symbol(Base, Decl(mixinWithUnknownRestParam.ts, 7, 1)) |
| 33 | + |
| 34 | +const instance = new Mixed(42) |
| 35 | +>instance : Symbol(instance, Decl(mixinWithUnknownRestParam.ts, 14, 5)) |
| 36 | +>Mixed : Symbol(Mixed, Decl(mixinWithUnknownRestParam.ts, 13, 5)) |
| 37 | + |
0 commit comments