Here is the JS I have trying to convert to TS:
/**
* @param {string} value The value to be formatted into a phone number
* @returns {string}
*/
export const formatPhoneString = (value) => {
const areaCode = value.substr(0, 3);
const prefix = value.substr(3, 3);
const suffix = value.substr(6, 4);
const output = `(${areaCode}) ${prefix}-${suffix}`;
return output;
};
/**
* Event handler for a phone number input to update the phone number's formatting
* @param {object} event js event object
*/
export const formatPhoneNumber = (event) => {
const targetElement = event.target;
// Get the value and remove all of the non-digit characters
const value = targetElement.value.replace(/\D/g, '');
if (value.length === 10) {
const output = formatPhoneString(value);
// Update the value of the input
targetElement.value = output;
}`enter code here`
};
When I try to pull this into new ts file getting type error for "event" What is the syntax for the event object in TS?