Text frames are flexible (unless they are locked), so I presume you are requesting a script that resizes a text frame while typing. I don't believe that is possible with scripting.
Hm, that should be possible with an eventlistener on the app object listening for AFTER_SELECTION_CHANGED events by filtering out the one text frame you are typing in. The problem would be how to tell InDesign to stop the behavior, to stop the function that is doing the change on the text frame. For that you need a second script.
But why not using the flexible text frame options that come with the textFramePreferences? Namely: