forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmixinWithUnknownRestParam.js
More file actions
36 lines (29 loc) · 918 Bytes
/
mixinWithUnknownRestParam.js
File metadata and controls
36 lines (29 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//// [tests/cases/conformance/classes/mixinWithUnknownRestParam.ts] ////
//// [mixinWithUnknownRestParam.ts]
// Repro for https://github.com/microsoft/TypeScript/issues/29707
// unknown[] should be a valid mixin constructor constraint, same as any[]
type ClassConstructor = new (...args: unknown[]) => {}
function mixin<C extends ClassConstructor>(Class: C) {
return class extends Class {}
}
class Base {
constructor(public x: number) {}
}
const Mixed = mixin(Base)
const instance = new Mixed(42)
//// [mixinWithUnknownRestParam.js]
"use strict";
// Repro for https://github.com/microsoft/TypeScript/issues/29707
// unknown[] should be a valid mixin constructor constraint, same as any[]
function mixin(Class) {
return class extends Class {
};
}
class Base {
x;
constructor(x) {
this.x = x;
}
}
const Mixed = mixin(Base);
const instance = new Mixed(42);