Typescript 4.5

This commit is contained in:
francesco
2021-11-22 15:11:14 +01:00
parent 9b2f925e63
commit cd3e09253c
6 changed files with 69 additions and 4 deletions

View File

@@ -115,6 +115,7 @@ function SampleApp() {
schema: testEntitySchema,
callbacks: testCallbacks,
name: "Test entity",
properties: ["subcollection_test_subcollection", "gallery"],
subcollections: [{
path: "test_subcollection",
schema: testEntitySchema,

View File

@@ -111,7 +111,7 @@
"react-router-dom": "^6.0.0",
"react-scripts": "^4.0.3",
"tsd": "0.17.0",
"typescript": "^4.4.3"
"typescript": "^4.5.2"
},
"files": [
"dist"

View File

@@ -161,6 +161,8 @@ export function buildColumnsFromSchema<M, AdditionalKey extends string, UserType
: {};
}, [additionalColumns]);
console.log("additionalColumns", additionalColumns)
// on ESC key press
useEffect(() => {
const escFunction = (event: any) => {

View File

@@ -329,7 +329,7 @@ export function EntityForm<M>({
const formFields = (
<Grid container spacing={4}>
{Object.entries<Property>(schemaProperties)
{Object.entries<Property>(schemaProperties as Record<string, Property<any>>)
.filter(([key, property]) => !isHidden(property))
.map(([key, property]) => {

View File

@@ -176,7 +176,7 @@ export interface EnumValueConfig {
* Record of properties of an entity or a map property
* @category Entity properties
*/
export type Properties<M extends { [Key: string]: any }> = {
export type Properties<M extends { [Key: string]: any } = any> = {
[k in keyof M]: Property<M[k]>;
};
@@ -337,7 +337,7 @@ export interface MapProperty<T extends { [Key: string]: any } = any> extends Bas
/**
* Record of properties included in this map.
*/
properties?: Properties<any>; // TODO: this should be Properties<T> but it breaks if building properties without `buildProperties`
properties?: Properties<Partial<T>>; // TODO: this should be Properties<T> but it breaks if building properties without `buildProperties`
/**
* Rules for validating this property

View File

@@ -278,5 +278,67 @@ export const siteConfig: FirebaseCMSAppProps = {
]
};
export const usersSchema = buildSchema({
name: "User",
properties: {
first_name: {
title: "First name",
dataType: "string"
},
last_name: {
title: "Last name",
dataType: "string"
},
email: {
title: "Email",
dataType: "string",
validation: {
email: true
}
},
phone: {
title: "Phone",
dataType: "string"
},
liked_products: {
dataType: "array",
title: "Liked products",
description: "Products this user has liked",
of: {
dataType: "reference",
path: "products"
}
},
picture: {
title: "Picture",
dataType: "map",
properties: {
large: {
title: "Large",
dataType: "string",
config: {
url: "image"
},
validation: {
url: true
}
},
thumbnail: {
title: "Thumbnail",
dataType: "string",
config: {
url: "image"
},
validation: {
url: true
}
}
},
previewProperties: ["large"]
}
}
});