Skip to content

@graphty/graphty-element / extend / OptionsFromSchema

Type Alias: OptionsFromSchema<S> ​

OptionsFromSchema<S> = { [K in keyof S]?: S[K]["default"] }

Defined in: graphty-element/src/algorithms/types/OptionSchema.ts:85

Type helper to extract the options type from a schema definition

This allows TypeScript to infer the correct types for algorithm options based on the schema definition.

Type Parameters ​

S ​

S extends OptionsSchema

Example ​

typescript
const schema = {
    dampingFactor: { type: 'number', default: 0.85, ... },
    maxIterations: { type: 'integer', default: 100, ... }
} as const;

type Options = OptionsFromSchema\<typeof schema\>;
// Options = { dampingFactor?: number; maxIterations?: number; }