Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

local test firebase functions with typescript

I have a problem with local test functions in typescript. Now, I used npm run build && firebase serve --only functions to run local functions, but every change I made on the code, I need to run this command again to see the result. I want to view real-time change without having to build the typescript code every time. Is there a solution to this problem?

like image 568
Pongsaphol Pongsawakul Avatar asked Jul 13 '26 14:07

Pongsaphol Pongsawakul


1 Answers

The Firebase emulator will pick up changes to JavaScript automatically while it's running. Since you're using TypeScript, you will have to compile to JavaScript in order for the emulator to pick up the change. You have two main choices:

  • Run npm run build again after each change
  • Tell the TypeScript compile to "watch" your source files and compile them whenever there is a change. You can do that with npx tsc --watch.
like image 67
Doug Stevenson Avatar answered Jul 15 '26 04:07

Doug Stevenson