ITerminalOptions: Make fields required #3948
Labels
breaking-change
Breaks API and requires a major version bump
help wanted
type/debt
Technical debt that could slow us down in the long run
Milestone
In #3667, all getOptions were replaced by their new equivalent:
this.dimensions.scaledCharLeft = Math.floor(this._terminal.getOption('letterSpacing') / 2);
became
this.dimensions.scaledCharLeft = Math.floor(this._terminal.options.letterSpacing! / 2);
Mind the "!" there, which is a shortcut to let typescript know that the variable is for sure defined. In fact, that can be safely assumed since the default parameters are filled in.
If the class ITerminalOptions is changed to have required fields which are not optional, it would be possible to have
this.dimensions.scaledCharLeft = Math.floor(this._terminal.options.letterSpacing / 2);
It was kind of explored in #3448 that
options: ITerminalOptions;
can be changed to
get options(): ITerminalOptions;
set options(options: Partial<ITerminalOptions>): void;
which would be an equivalent of the current code. Just ITerminalOptions is changed to have required fields.
There are some settings though which can be "undefined":
This would also make the code more aligned, since the typings have ITerminalOptions with all fields optional and the internal ITerminalOptions have required fields.
The breaking change part here lies in the fact that addons can use ITerminalOptions as type. If this is passed as a parameter, they would need to change the parameter to Partial<ITerminalOptions>.
The text was updated successfully, but these errors were encountered: