Repository: excalidraw/excalidraw
File: src/element/textWysiwyg.tsx (TypeScript)

Code before:
  excalidrawContainer: HTMLDivElement | null;
  app: App;
}) => {
  const textPropertiesUpdated = (
    updatedElement: ExcalidrawTextElement,
    editable: HTMLTextAreaElement,
  ) => {
    const currentFont = editable.style.fontFamily.replace(/"/g, "");
    if (
      getFontFamilyString({ fontFamily: updatedElement.fontFamily }) !==
      currentFont
    ) {
      return true;
    }
    if (`${updatedElement.fontSize}px` !== editable.style.fontSize) {
      return true;
    }
    return false;
  };
  let originalContainerHeight: number;

  const updateWysiwygStyle = () => {
    const appState = app.state;
    const updatedElement = Scene.getScene(element)?.getElement(
      id,
    ) as ExcalidrawTextElement;
    if (!updatedElement) {
      return;
    }
    const { textAlign, verticalAlign } = updatedElement;

    const approxLineHeight = getApproxLineHeight(getFontString(updatedElement));
    if (updatedElement && isTextElement(updatedElement)) {
      let coordX = updatedElement.x;
      let coordY = updatedElement.y;
      const container = getContainerElement(updatedElement);
      let maxWidth = updatedElement.width;

      let maxHeight = updatedElement.height;
      let width = updatedElement.width;
      // Set to element height by default since that's
      // what is going to be used for unbounded text
      let height = updatedElement.height;
      if (container && updatedElement.containerId) {
        const propertiesUpdated = textPropertiesUpdated(
          updatedElement,
          editable,
        );
        // using editor.style.height to get the accurate height of text editor
        const editorHeight = Number(editable.style.height.slice(0, -2));
        if (editorHeight > 0) {

Review comment (suggestion):
let's also get rid of the `as ExcalidrawTextElemen` — no longer needed and reduces type safety

Code after:
  excalidrawContainer: HTMLDivElement | null;
  app: App;
}) => {
  const textPropertiesUpdated = (
    updatedElement: ExcalidrawTextElement,
    editable: HTMLTextAreaElement,
  ) => {
    const currentFont = editable.style.fontFamily.replace(/"/g, "");
    if (
      getFontFamilyString({ fontFamily: updatedElement.fontFamily }) !==
      currentFont
    ) {
      return true;
    }
    if (`${updatedElement.fontSize}px` !== editable.style.fontSize) {
      return true;
    }
    return false;
  };
  let originalContainerHeight: number;

  const updateWysiwygStyle = () => {
    const appState = app.state;
    const updatedElement =
      Scene.getScene(element)?.getElement<ExcalidrawTextElement>(id);
    if (!updatedElement) {
      return;
    }
    const { textAlign, verticalAlign } = updatedElement;

    const approxLineHeight = getApproxLineHeight(getFontString(updatedElement));
    if (updatedElement && isTextElement(updatedElement)) {
      let coordX = updatedElement.x;
      let coordY = updatedElement.y;
      const container = getContainerElement(updatedElement);
      let maxWidth = updatedElement.width;

      let maxHeight = updatedElement.height;
      let width = updatedElement.width;
      // Set to element height by default since that's
      // what is going to be used for unbounded text
      let height = updatedElement.height;
      if (container && updatedElement.containerId) {
        const propertiesUpdated = textPropertiesUpdated(
          updatedElement,
          editable,
        );
        // using editor.style.height to get the accurate height of text editor
        const editorHeight = Number(editable.style.height.slice(0, -2));
        if (editorHeight > 0) {
          height = editorHeight;