Performance
Typia / Nestia
Using typia or nestia to do type check with complex type will increase compile time and build size.
This includes all function under typia, return type of Controller in api.
Example:
interface ObjectFieldTemplateContext {
schema: RJSFSchema;
uiSchema: UiSchema;
setSchema: Dispatch<SetStateAction<RJSFSchema>>;
setUiSchema: Dispatch<SetStateAction<UiSchema>>;
}
export default function ObjectFieldTemplate(
props: ObjectFieldTemplateProps,
): null {
const context: unknown = props.registry.formContext;
typia.assertGuard<{ objectFieldTemplate: ObjectFieldTemplateContext }>(
context,
);
return null;
}
The above code will cause compile time to increase 50 seconds.
Workaround:
-
Trim the type and remove unused value:
export interface ObjectFieldTemplateContext { templates: string[]; setSchema: Dispatch<SetStateAction<RJSFSchema>>; setUiSchema: Dispatch<SetStateAction<UiSchema>>; } -
Use a simpler type. For example, use
Record<string, unknown>instead ofRJSFSchemaorUiSchema.