Loosen type of constructor, to allow patterns as well as values

This commit is contained in:
Tony Garnock-Jones 2021-02-25 11:33:11 +01:00
parent c46566e5a0
commit 074fc5db98
1 changed files with 2 additions and 2 deletions

View File

@ -71,11 +71,11 @@ export class Record<T extends object = DefaultPointer> extends Array<Value<T>> {
}).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);
}
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 ctor: RecordConstructor<T> = (...fields: Value<T>[]): Record<T> => {
if (fields.length !== arity) {