UNPKG

easy-constructor

Version:

JavaScript class constructors without the boilerplate

1 lines 1.48 kB
{"version":3,"sources":["../../src/types/EasyConstructorOptions.ts"],"sourcesContent":["/**\n * Configuration of the `easyConstructor` function.\n */\nexport interface EasyConstructorOptions<TOmit, TOptional> {\n /**\n * Exclude these fields from the easy constructor.\n *\n * Use it to remove getters and setters from the Easy Constructor.\n * @example\n * ```ts\n * class ExampleClass {\n * property1: string;\n *\n * get property2(): number {\n * return 42\n * }\n *\n * static create = easyConstructor(ExampleClass, {\n * optional: ['property2']\n * });\n * }\n *\n * // The `property2` getter is removed from the easy constructor\n * const instance = ExampleClass.create({ property1: 'value' });\n * ```\n */\n omit?: TOmit[];\n /**\n * Make these fields optional in the easy constructor.\n *\n * The class constructor treats all fields as required by default. If you\n * have an optional field or a field with a default value, do mark it as\n * optional here.\n * @example\n * ```ts\n * class ExampleClass {\n * property1: string;\n * property2?: number;\n * property3: boolean = true;\n *\n * static create = easyConstructor(ExampleClass, {\n * optional: ['property2', 'property3']\n * });\n * }\n * const instance = ExampleClass.create({ property1: 'value' });\n * ```\n */\n optional?: TOptional[];\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}