@tstdl/base 0.91.31 → 0.91.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.91.31",
3
+ "version": "0.91.32",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -2,6 +2,7 @@ import type { Decorator } from '../../reflection/index.js';
2
2
  import type { TypedOmit } from '../../types.js';
3
3
  import type { SchemaTestable } from '../schema.js';
4
4
  import type { SchemaPropertyReflectionData } from './types.js';
5
- export type SchemaPropertyDecoratorOptions = TypedOmit<SchemaPropertyReflectionData, 'schema'>;
6
- export declare function Property(schema: SchemaTestable, options?: SchemaPropertyDecoratorOptions): Decorator<'property' | 'accessor'>;
5
+ export type SchemaPropertyDecoratorOptions = SchemaPropertyReflectionData;
6
+ export type SchemaPropertyDecoratorOptionsWithoutSchema = TypedOmit<SchemaPropertyReflectionData, 'schema'>;
7
+ export declare function Property(schema: SchemaTestable, options?: SchemaPropertyDecoratorOptionsWithoutSchema): Decorator<'property' | 'accessor'>;
7
8
  export declare function Property(options: SchemaPropertyDecoratorOptions): Decorator<'property' | 'accessor'>;
@@ -159,9 +159,12 @@ function getObjectSchemaPropertiesFromReflection(metadata, type) {
159
159
  for (const [key, propertyMetadata] of metadata.properties) {
160
160
  const reflectionData = propertyMetadata.data.tryGet('schema');
161
161
  if (isUndefined(reflectionData?.schema) && (propertyMetadata.type == Object)) {
162
- throw new Error(`Schema of property "${String(key)}" on type ${type.name} is inferred as Object. This is most likely unwanted and happens when the property is defined as partial or the type is an union. Use an explicit @Property(Object) if this is wanted.`);
162
+ throw new Error(`Schema of property "${String(key)}" on type ${type.name} is inferred as Object. This is most likely unwanted and happens if the property is defined as partial or the type is an union. Use an explicit @Property(Object) if this is wanted.`);
163
163
  }
164
164
  let propertySchema = reflectionData?.schema ?? propertyMetadata.type;
165
+ if (isUndefined(propertySchema)) {
166
+ throw new Error(`Could not infer schema for "${String(key)}" on type ${type.name}. This happens if neither explicit @Property(type) is used nor reflection metadata is available.`);
167
+ }
165
168
  if (reflectionData?.array == true) {
166
169
  propertySchema = array(propertySchema);
167
170
  }