DialogLayout[] dialog.ts
Declarations #
4 declarations
dialog_layouts #
dialog_layouts
DialogLayout #
DialogLayout
DialogLayout DialogParams #
DialogParams
DialogParams<T> This pattern is based on:
https://github.com/ivanhofer/sveltekit-typescript-showcase/blob/main/src/01-props/09-svelte-component/Component.svelte
The main limitation is that the generic cannot be inferred automatically,
so we use to_dialog_params to construct instances in most cases.
Definining DialogParams with no concrete T lacks typechecking for props.
generics
T
constraint
Component<any>default
Component<any>Component
type
Tprops
type
ComponentProps<T>dialog_props
type
Partial<ComponentProps<typeof Dialog>> | undefinedto_dialog_params #
to_dialog_params
<T extends Component<any>>(Component: T, props: ComponentProps<T>, dialog_props?: Partial<Record<string, any>> | undefined): DialogParams<T> This helper function is needed to construct DialogParams with type safety. It uses TypeScript's inferred generics for functions, which do not work for plain objects as of v5.0.4. * ContextmenuParams uses a similar strategy.
Component
type
Tprops
type
ComponentProps<T>dialog_props?
type
Partial<Record<string, any>> | undefinedoptional
returns
DialogParams<T>