{"id":13683586,"url":"https://github.com/gilamran/tsc-watch","last_synced_at":"2025-05-13T19:13:59.153Z","repository":{"id":19228333,"uuid":"86547958","full_name":"gilamran/tsc-watch","owner":"gilamran","description":"The TypeScript compiler with --watch and a new onSuccess argument","archived":false,"fork":false,"pushed_at":"2024-11-13T13:32:59.000Z","size":686,"stargazers_count":688,"open_issues_count":11,"forks_count":61,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-05T21:06:40.054Z","etag":null,"topics":["nodemon","onchange","tsc","typescript","watch"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilamran.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-29T06:47:54.000Z","updated_at":"2025-05-01T15:35:02.000Z","dependencies_parsed_at":"2024-06-17T10:18:46.681Z","dependency_job_id":"57cee944-e7f8-4eb2-a446-32e421705566","html_url":"https://github.com/gilamran/tsc-watch","commit_stats":{"total_commits":281,"total_committers":31,"mean_commits":9.064516129032258,"dds":0.501779359430605,"last_synced_commit":"3b21f1e6bfe0b38ca923b1b772d2bd682231cbb7"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilamran%2Ftsc-watch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilamran%2Ftsc-watch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilamran%2Ftsc-watch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilamran%2Ftsc-watch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilamran","download_url":"https://codeload.github.com/gilamran/tsc-watch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253474206,"owners_count":21914227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nodemon","onchange","tsc","typescript","watch"],"created_at":"2024-08-02T13:02:16.612Z","updated_at":"2025-05-13T19:13:59.131Z","avatar_url":"https://github.com/gilamran.png","language":"TypeScript","funding_links":[],"categories":["JavaScript","TypeScript"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/gilamran/tsc-watch.svg?branch=master)](https://travis-ci.com/gilamran/tsc-watch)\n\n# The nodemon for TypeScript\n\n`tsc-watch` starts the installed TypeScript compiler (`tsc`) with `--watch` parameter, with the ability to react to compilation status.\n`tsc-watch` was created to allow an easy dev process with TypeScript. Commonly used to restart a node server, similar to nodemon but for TypeScript.\n\n**Anything that you can do with `tsc` you can do with `tsc-watch`, the only difference is that `tsc-watch` can react to compilation status.**\n\n| Argument                          | Description                                                                                                                                         |\n| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `--onSuccess COMMAND`             | Executes `COMMAND` on **every successful** compilation.                                                                                             |\n| `--onFirstSuccess COMMAND`        | Executes `COMMAND` on the **first successful** compilation.                                                                                         |\n| `--onEmit COMMAND`                | Executes debounced `COMMAND` on **every emitted file**, ignoring unchanged files and disregards compilation success or failure.                     |\n| `--onEmitDebounceMs DELAY`        | Delay by which to debounce `--onEmit` (default: 300).                                                                                               |\n| `--onFailure COMMAND`             | Executes `COMMAND` on **every failed** compilation.                                                                                                 |\n| `--onCompilationStarted COMMAND`  | Executes `COMMAND` on **every compilation start** event (initial and incremental).                                                                  |\n| `--onCompilationComplete COMMAND` | Executes `COMMAND` on **every successful or failed** compilation.                                                                                   |\n| `--maxNodeMem`                    | Calls `node` with a specific memory limit `max_old_space_size`, to use if your project needs more memory.                                           |\n| `--noColors`                      | By default tsc-watch adds colors the output with green\u003cbr\u003eon success, and in red on failure. \u003cbr\u003eAdd this argument to prevent that.                 |\n| `--noClear`                       | In watch mode the `tsc` compiler clears the screen before reporting\u003cbr\u003eAdd this argument to prevent that.                                           |\n| `--signalEmittedFiles`            | Will run `tsc` compiler with `--listEmittedFiles`, but hiding TSFILE lines. Use it to enable `file_emitted` event, while keeping tsc stdout silent. |\n| `--silent`                        | Do not print any messages on stdout.                                                                                                                |\n| `--compiler PATH`                 | The `PATH` will be used instead of typescript compiler.\u003cbr\u003eDefault is `typescript/bin/tsc`                                                          |\n\nNotes:\n\n- That all the above `COMMAND`s will be killed on process exit. (Using `SIGTERM`)\n\n- A `COMMAND` is a single command and not multi command like `script1.sh \u0026\u0026 script2.sh`\n\n- Any child process (`COMMAND`) will be terminated before creating a new one.\n\n## Install\n\n```sh\nnpm install tsc-watch --save-dev\n```\n\n```sh\n## for command-line usage\nnpm install -g typescript tsc-watch\n```\n\n## Usage\n\n### From Command-Line\n\n```sh\n## Watching a project (with tsconfig.json)\ntsc-watch --onSuccess \"node ./dist/server.js\"\n\n## Beep on failure\ntsc-watch --onFailure \"echo Beep! Compilation Failed\"\n\n## Watching a single file\ntsc-watch server.ts --outDir ./dist --onSuccess \"node ./dist/server.js\"\n\n## Custom compiler\ntsc-watch --onSuccess \"node ./dist/server.js\" --compiler my-typescript/bin/tsc\n```\n\n### From npm script\n\n```\n\"dev-server\": \"tsc-watch --noClear -p ./src/tsconfig.json --onSuccess \\\"node ./dist/server.js\\\"\",\n```\n\n### From javascript\n\nYou can see a detailed example [here](https://github.com/gilamran/tsc-watch/blob/master/tsc-watch-client-example.js)\n\nThe client is implemented as an instance of `Node.JS`'s `EventEmitter`, with the following events:\n\n- `started` - Emitted upon the compilation start (initial or incremental).\n- `first_success` - Emitted upon first successful compilation.\n- `subsequent_success` - Emitted upon every subsequent successful compilation.\n- `compile_errors` - Emitted upon every failing compilation.\n- `file_emitted` - Emitted upon every file transpiled if `--listEmittedFiles` is used.\n\nOnce subscribed to the relevant events, start the client by running `watch.start()`\n\nTo kill the client, run `watch.kill()`\n\nExample usage:\n\n```javascript\n// Using CommonJS:\nconst { TscWatchClient } = require('tsc-watch/client');\n// Using ES6 import:\nimport { TscWatchClient } from 'tsc-watch/client';\n\nconst watch = new TscWatchClient();\n\nwatch.on('started', () =\u003e {\n  console.log('Compilation started');\n});\n\nwatch.on('first_success', () =\u003e {\n  console.log('First success!');\n});\n\nwatch.on('success', () =\u003e {\n  // Your code goes here...\n});\n\nwatch.on('compile_errors', () =\u003e {\n  // Your code goes here...\n});\n\nwatch.start('--project', '.');\n\ntry {\n  // do something...\n} catch (e) {\n  watch.kill(); // Fatal error, kill the compiler instance.\n}\n```\n\nNotes:\n\n- The (`onSuccess`) `COMMAND` will not run if the compilation failed.\n- The (`onEmit`) `COMMAND` will not run if the compilation succeeded with no changed files, unless it is the first success.\n- The (`onEmit`) `COMMAND` will run even if the compilation failed, but emitted changed files.\n- The (`onEmit`) `COMMAND` will not run 100 times for 100 files, due to `--onEmitDebounce`\n- The (`onEmit`) `COMMAND` is not cancelling the `onSuccess`/`onFirstSuccess`/`onFailure`/`onCompilationComplete`/`onCompilationStarted` commands and vice versa.\n- `tsc-watch` is using the currently installed TypeScript compiler.\n- `tsc-watch` is not changing the compiler, just adds the new arguments, compilation is the same, and all other arguments are the same.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilamran%2Ftsc-watch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilamran%2Ftsc-watch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilamran%2Ftsc-watch/lists"}