diff --git a/src/types/columns.test.ts b/src/types/columns.test.ts index e7f0cc57..5623b7b1 100644 --- a/src/types/columns.test.ts +++ b/src/types/columns.test.ts @@ -37,6 +37,13 @@ Deno.test('ColumnsMap', async (t) => { // @ts-expect-error ibid assertEquals(columns.size, ['0']) }) + await t.step('set columns are permissible', () => { + const columns = new ColumnsMap() + // @ts-expect-error ts thinks size is protected property + columns['set'] = ['0'] + // @ts-expect-error ibid + assertEquals(columns.set, ['0']) + }) await t.step('missing columns are undefined', () => { const columns = new ColumnsMap() columns['a'] = ['0'] diff --git a/src/types/columns.ts b/src/types/columns.ts index eb5ca0de..db7a5d01 100644 --- a/src/types/columns.ts +++ b/src/types/columns.ts @@ -15,8 +15,14 @@ const columnMapAccessorProxy = { prop: symbol | string, receiver: ColumnsMap, ) { - // Map.size exists, so we need to shadow it with the column contents - if (prop === 'size') return target.get('size') + // Map instance methods/properties that could plasubily be column names: + if ( + ['clear', 'delete', 'keys', 'set', 'values', 'size'].includes( + prop as string, + ) + ) { + return target.get(prop as string) + } const value = Reflect.get(target, prop, receiver) if (typeof value === 'function') return value.bind(target) if (prop === Symbol.iterator) return target[Symbol.iterator].bind(target)