Loosen type of constructor, to allow patterns as well as values
This commit is contained in:
parent
c46566e5a0
commit
074fc5db98
|
@ -71,11 +71,11 @@ export class Record<T extends object = DefaultPointer> extends Array<Value<T>> {
|
||||||
}).join(', ') + ')';
|
}).join(', ') + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
static makeConstructor<T extends object = DefaultPointer>(labelSymbolText: string, fieldNames: string[]): RecordConstructor<T> {
|
static makeConstructor<T extends object = any>(labelSymbolText: string, fieldNames: string[]): RecordConstructor<T> {
|
||||||
return Record.makeBasicConstructor<T>(Symbol.for(labelSymbolText), fieldNames);
|
return Record.makeBasicConstructor<T>(Symbol.for(labelSymbolText), fieldNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
static makeBasicConstructor<T extends object = DefaultPointer>(label: Value<T>, fieldNames: string[]): RecordConstructor<T> {
|
static makeBasicConstructor<T extends object = any>(label: Value<T>, fieldNames: string[]): RecordConstructor<T> {
|
||||||
const arity = fieldNames.length;
|
const arity = fieldNames.length;
|
||||||
const ctor: RecordConstructor<T> = (...fields: Value<T>[]): Record<T> => {
|
const ctor: RecordConstructor<T> = (...fields: Value<T>[]): Record<T> => {
|
||||||
if (fields.length !== arity) {
|
if (fields.length !== arity) {
|
||||||
|
|
Loading…
Reference in New Issue