question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Watching for changes & Typescript

See original GitHub issue

Hi,

As this is the recommended way to run functions locally, is there a way to use Typescipt and to watch files?

Thanks,

Expected Behaviour: Running functions-framework --watch would restart the functions framework if any of the *.js files in the app (eg the main index.js and it’s dependancies) change

Actual Behaviour: New feature

Steps to Reproduce the Problem New feature

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
quantuminformationcommented, Jul 13, 2019

I just use

"debug-watch": "npx tsc-watch --onSuccess 'npx @google-cloud/functions-framework --target=sendMail'"
3reactions
tomarderncommented, Jul 29, 2019

Based on @QuantumInformation’s excellent answer, we’ve ended up using the following:

"dev": "tsc-watch --onSuccess 'functions-framework --target=testFuction'"

Then just npm run dev.

Bonus: If you want to add the typescript source files to a different folder /app, then:

  • In tsconfig.json change "outDir": "./dist" and "rootDir":"./app"
  • In package.json change to "main":"./dist/index.js"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Configuring Watch - TypeScript
Compiler supports configuring how to watch files and directories using compiler flags in TypeScript 3.8+, and environment variables before that.
Read more >
How to watch and compile all TypeScript sources?
Run the compiler in watch mode. Watch input files and trigger recompilation on changes. The implementation of watching files and directories can ...
Read more >
Watch for Object Changes with JavaScript by Typescript · GitHub
Watch for Object Changes with JavaScript by Typescript · GitHub. Instantly share code, notes, and snippets.
Read more >
tsc-watch - npm
tsc-watch starts a TypeScript compiler with --watch parameter, with the ability to react to compilation status. tsc-watch was created to ...
Read more >
3 ways to watch and run your TypeScript projects
... the project on every code change?” TypeScript has evolved greatly in the last few years, but running the project after building in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found