geschrieben ist.
Code: Select all
function InputMask(options) {
options = extend({
formatCharacters: null,
pattern: null,
isRevealingMask: false,
placeholderChar: DEFAULT_PLACEHOLDER_CHAR,
selection: {
start: 0,
end: 0
},
value: ''
}, options)
}
< /code>
Wie kann dieser Code am besten in ES6 konvertiert werden? Typscript ist vorzuziehen und darüber hinaus. Sollten wir eine klassenbasierte Transformation haben oder funktionieren funktionsbasierte Arbeiten? < /P>
export default class InputMask {
constructor(options: InputMaskOptions) {
options = extend(
{
formatCharacters: null,
pattern: '',
isRevealingMask: false,
placeholderChar: DEFAULT_PLACEHOLDER_CHAR,
selection: { start: 0, end: 0 },
value: '',
},
options,
);
this.placeholderChar = options.placeholderChar;
this.formatCharacters = mergeFormatCharacters(options.formatCharacters);
}
}
Code: Select all
Argument of type 'FormatCharacters | undefined' is not assignable to parameter of type 'FormatCharacters'.
Type 'undefined' is not assignable to type 'FormatCharacters'