UNPKG

@nozbe/watermelondb

Version:

Build powerful React Native and React web apps that scale from hundreds to tens of thousands of records and remain fast

29 lines (25 loc) 869 B
// @flow import invariant from '../utils/common/invariant' import type { ColumnName } from '../Schema' // eslint-disable-next-line export function ensureDecoratorUsedProperly( columnName: ColumnName, target: Object, key: string, descriptor: Object, ): void { invariant( columnName, `Pass column name (raw field name) to the decorator - error in ${target.constructor.name}.prototype.${key} given.`, ) if (descriptor) { invariant( 'initializer' in descriptor, `Model field decorators can only be used for simple properties - method, setter or getter ${target.constructor.name}.prototype.${key} given.`, ) invariant( typeof descriptor.initializer !== 'function', `Model field decorators must not be used on properties with a default value - error in "${target.constructor.name}.prototype.${key}".`, ) } }