Small builders.ts types fix

This commit is contained in:
francesco
2021-05-05 12:22:27 +02:00
parent 0953fd250b
commit 2ff6f71060
3 changed files with 16 additions and 12 deletions

View File

@@ -52,16 +52,13 @@ export const testEntitySchema = buildSchema({
status,
context
}) => {
console.log("custom onPreSave", collectionPath, id);
getNavigationFrom({
return getNavigationFrom({
path: `${collectionPath}/${id}`,
context
}).then((result) => console.log("getNavigationFrom", result));
if (!values.empty_string) values.empty_string = "";
return values;
}).then((navigation) => {
console.log("navigation", navigation);
return values;
});
},
properties: {
actions: {

View File

@@ -3,6 +3,7 @@ import {
EntitySchema,
EntityValues,
EnumValueConfig,
Properties,
PropertiesOrBuilder,
Property,
PropertyOrBuilder
@@ -73,12 +74,18 @@ export function buildProperty(
* same properties
* @param properties
*/
export function buildProperties<S extends EntitySchema<Key>, Key extends string>(
properties: PropertiesOrBuilder<S, Key>
): PropertiesOrBuilder<S, Key> {
export function buildProperties<Key extends string>(
properties: Properties<Key>
): Properties<Key> {
return properties;
}
export function buildPropertiesOrBuilder<S extends EntitySchema<Key>, Key extends string>(
propertiesOrBuilder: PropertiesOrBuilder<S, Key>
): PropertiesOrBuilder<S, Key> {
return propertiesOrBuilder;
}
export function buildEnumValueConfig(
enumValueConfig: EnumValueConfig
): EnumValueConfig {

View File

@@ -491,7 +491,7 @@ export type EnumValueConfig = {
/**
* Record of properties of an entity or a map property
*/
export type Properties<Key extends string, T extends any = any> = Record<Key, Property<T>>;
export type Properties<Key extends string = string, T extends any = any> = Record<Key, Property<T>>;
export type PropertyBuilderProps<S extends EntitySchema<Key> = EntitySchema<any>, Key extends string = Extract<keyof S["properties"], string>> =
{