Add comments

This commit is contained in:
AriGunawan 2022-10-15 09:11:23 +10:00
parent c246d07c60
commit a1b42765d0
4 changed files with 6 additions and 2 deletions

View File

@ -15,7 +15,7 @@ export interface IReactZodWebPartProps {
} }
export default class ReactZodWebPart extends BaseClientSideWebPart<IReactZodWebPartProps> { export default class ReactZodWebPart extends BaseClientSideWebPart<IReactZodWebPartProps> {
private _sp: SPFI; private _sp!: SPFI;
public async render(): Promise<void> { public async render(): Promise<void> {
let element: React.ReactElement; let element: React.ReactElement;

View File

@ -7,6 +7,7 @@ const dateFormatter = new Intl.DateTimeFormat([], {
weekday: "short", weekday: "short",
}); });
// Setup schema
const FormResultSchema = z.object({ const FormResultSchema = z.object({
Id: z.number(), Id: z.number(),
Title: z.string(), Title: z.string(),
@ -27,6 +28,7 @@ const FormResultSchema = z.object({
}); });
const FormResultsSchema = z.array(FormResultSchema); const FormResultsSchema = z.array(FormResultSchema);
// Generate type from schema
type FormResultModel = z.infer<typeof FormResultSchema>; type FormResultModel = z.infer<typeof FormResultSchema>;
type FormResultsModel = z.infer<typeof FormResultsSchema>; type FormResultsModel = z.infer<typeof FormResultsSchema>;

View File

@ -24,6 +24,8 @@ export default class SharePointHelper {
"Contact/Title", "Contact/Title",
"Email" "Email"
)(); )();
// Parse data into a fully typed object
return FormResultsSchema.parse(items); return FormResultsSchema.parse(items);
} }
} }

View File

@ -12,9 +12,9 @@
"skipLibCheck": true, "skipLibCheck": true,
"outDir": "lib", "outDir": "lib",
"inlineSources": false, "inlineSources": false,
"strictNullChecks": false,
"noUnusedLocals": false, "noUnusedLocals": false,
"noImplicitAny": true, "noImplicitAny": true,
"strict": true,
"typeRoots": [ "typeRoots": [
"./node_modules/@types", "./node_modules/@types",