mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
* Use typescript-strict-plugin to iteratively turn on strict * Add strict testing to pipeline Can be executed locally through either `npm run test:types` for full type checking including spec files, or `npx tsc-strict` for only tsconfig.json included files. * turn on strict for scripts directory * Use plugin for all tsconfigs in monorepo vscode is capable of executing tsc with plugins, but uses the most relevant tsconfig to do so. If the plugin is not a part of that config, it is skipped and developers get no feedback of strict compile time issues. These updates remedy that at the cost of slightly more complex removal of the plugin when the time comes. * remove plugin from configs that extend one that already has it * Update workspace settings to honor strict plugin * Apply strict-plugin to native message test runner * Update vscode workspace to use root tsc version * `./node_modules/.bin/update-strict-comments` 🤖 This is a one-time operation. All future files should adhere to strict type checking. * Add fixme to `ts-strict-ignore` comments * `update-strict-comments` 🤖 repeated for new merge files
50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
// FIXME: Update this file to be type safe and remove this and next line
|
|
// @ts-strict-ignore
|
|
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
|
|
|
|
import { SendFormConfig } from "./abstractions/send-form-config.service";
|
|
import { SendOptionsComponent } from "./components/options/send-options.component";
|
|
import { SendDetailsComponent } from "./components/send-details/send-details.component";
|
|
import { SendFileDetailsComponent } from "./components/send-details/send-file-details.component";
|
|
import { SendTextDetailsComponent } from "./components/send-details/send-text-details.component";
|
|
/**
|
|
* The complete form for a send. Includes all the sub-forms from their respective section components.
|
|
* TODO: Add additional form sections as they are implemented.
|
|
*/
|
|
export type SendForm = {
|
|
sendDetailsForm?: SendDetailsComponent["sendDetailsForm"];
|
|
sendTextDetailsForm?: SendTextDetailsComponent["sendTextDetailsForm"];
|
|
sendFileDetailsForm?: SendFileDetailsComponent["sendFileDetailsForm"];
|
|
sendOptionsForm?: SendOptionsComponent["sendOptionsForm"];
|
|
};
|
|
|
|
/**
|
|
* A container for the {@link SendForm} that allows for registration of child form groups and patching of the send
|
|
* to be updated/created. Child form components inject this container in order to register themselves with the parent form
|
|
* and access configuration options.
|
|
*
|
|
* This is an alternative to passing the form groups down through the component tree via @Inputs() and form updates via
|
|
* @Outputs(). It allows child forms to define their own structure and validation rules, while still being able to
|
|
* update the parent send.
|
|
*/
|
|
export abstract class SendFormContainer {
|
|
/**
|
|
* The configuration for the send form.
|
|
*/
|
|
readonly config: SendFormConfig;
|
|
|
|
/**
|
|
* The original send that is being edited/cloned. Used to pre-populate the form and compare changes.
|
|
*/
|
|
readonly originalSendView: SendView | null;
|
|
|
|
abstract registerChildForm<K extends keyof SendForm>(
|
|
name: K,
|
|
group: Exclude<SendForm[K], undefined>,
|
|
): void;
|
|
|
|
abstract onFileSelected(file: File): void;
|
|
|
|
abstract patchSend(updateFn: (current: SendView) => SendView): void;
|
|
}
|