dynamodb-toolbox
dynamodb-toolbox copied to clipboard
Entity constructor not accepting an argument with spread operator used in attributes key
I updated to version 0.3 today in a Typescript environment and all of a sudden my attributes key in my entity definition is showing that it has an error (in VS Code).
This looks like a bug, but I need to do a bit more research. Thanks for reporting.
Hey @ryantomaselli, thanks for opening this issue.
I know this is an old issue but the following seems to be working, note that you have to use as const at the moment to make it work.
const getCommonEntityAttributes = () => {
return {
id: { type: 'string' },
name: { type: 'string' },
test: { type: 'string' }
} as const
}
const commonEntityConfig = {
typeAlias: 'test_et'
} as const
const TestEntity = new Entity({
name: 'TestEntity',
...commonEntityConfig,
attributes: {
pk: { type: 'string', partitionKey: true },
sk: { type: 'string', sortKey: true },
asd: 'string',
set: 'set',
map: 'map',
...getCommonEntityAttributes()
},
table: TestTable
})
I'll be closing this issue for now but feel free to ping me if you need any further help.