Skip to content

tsc: watch mode doesn't discover new files #4553

Description

  • tsconfig with watch: true
  • start tsc
  • add a new file

Observe: it is not transpiled.

Activity

  1. mhegazy commented on Sep 18, 2015

    @mhegazy
    Contributor

    looks like another place where we should use the new node watch APIs: see #4643

  2. alexeagle commented on Oct 5, 2015

    @alexeagle
    Contributor

    +1 to have this soon. Is it for 1.7 like in #5076 or for 1.8 like here?

  3. zhengbli commented on Oct 5, 2015

    @zhengbli

    Alex Eagle (@alexeagle) these two issues are both for 1.7

  4. dsebastien commented on Oct 10, 2015

    @dsebastien

    +1 to have this soon(er), this is annoying :)

  5. mhegazy commented on Oct 15, 2015

    @mhegazy
    Contributor

    Dirk Bäumer (@dbaeumer) can you give latest a try?

  6. jmls commented on Dec 16, 2016

    @jmls

    Hmm - I'm using 2.0.10 and tsc -w does not spot new files. If I ctrl-c and restart, it then transpiles

  7. zhengbli commented on Dec 21, 2016

    @zhengbli

    jmls (@jmls) Can you provide the following info:

    • your os
    • your node version
    • are you using a network mounted file system?
    • if possible, a small project that repros the issue.
  8. jmls commented on Dec 21, 2016

    @jmls

    Of course.

    node: 4.6.1, 7.0.0 and 7.2.0
    os: c9.io, running ubuntu 4.2.0-c9 #2 SMP x86_64 x86_64 x86_64 GNU/Linux

    demo project at https://github.com/jmls/tsc-watch

    I've created a new file by copying in the shell (cp part1.ts part2.ts) and creating a new file in the ide

  9. zhengbli commented on Dec 21, 2016

    @zhengbli

    Do you run tsc -w from project root path instead of from src? If so this is a known issue, as node's file watcher doesn't support recursive watching on linux.

  10. jmls commented on Dec 21, 2016

    @jmls

    I do - but I am amazed that tsc still uses fw.watch if it has such a fundamental problem.
    Are you looking to fix this by using a package like chokidar ?

  11. zhengbli commented on Dec 21, 2016

    @zhengbli

    Indeed it is not ideal and creating a file watcher for node is out of the domain of our main focus. If there are no signs in addressing this in upcoming node updates, I do think a third-party package is the most likely approach. Though we are very cautious in adding third-party dependencies (currently we have none).

  12. OliverUv commented on Apr 8, 2017

    @OliverUv

    This is a very relevant issue to my organization. I would like you to re-open it.

    We, and I assume many others, do our building in Docker containers, with source directories mounted in volumes. This gives us the assurance that all devs use the same environment as production. The Docker container, of course, is running Linux, where node's fs.watch is broken.

    We let the tsc --watch process inside Docker pick up changes made on the outside, giving us a very nice dev cycle where compilation and tests are re-run automatically whenever a file is changed.

    We absolutely want to keep using the native tsc --watch, since external modules have many issues:

    • Can never do as good a job with incremental recompilation as tsc can
    • Stop working if tsc changes
    • Maintainers stop maintaining them

    So I ask you: Given the prevalence of people using Docker for development, please start considering Linux a supported platform, and ensure that your amazing --watch mode is fully supported there as well.

    Since you don't want strict dependencies on external libraries, I suggest doing this with an optionalDependency.

  13. ORESoftware commented on Jun 20, 2017

    @ORESoftware
    const chokidar = require('chokidar');
    const watcher = chokidar.watch(<dir>);
    
    watcher.on('add', function(p){
     /// a file was added with path = p
    });

    this should be easy to add to tsc -w, right?

  14. ORESoftware commented on Jun 20, 2017

    @ORESoftware

    Alright so I already had created a tsc --watch wrapper that could spawn separate watchers for each tsconfig.json file in a project. tsc -w only seems to be able to watch for changes that pertain to one tsconfig.json file...

    So I added this chokidar watch feature to the same project that can take into account multiple tsconfig.json files, so now the watcher will restart when a new file is added. I created this recently, so it's nothing great, but star it if you are interested in me making it better.

    https://github.com/ORESoftware/tsc-multi-watch

    screenshot 2017-06-19 22 20 06

  15. natew commented on May 26, 2018

    @natew

    Is this supposed to work? I don't see it with my system. Frustrating for bigger monorepos because have to restart a bunch of watchers for any file addition anywhere.

  16. natew commented on May 26, 2018

    @natew

    Ah figured it out, I had this in my tsconfig:

    "include": ["/**/*"],
    

    Changing to this works:

    "include": ["**/*"],
    
  17. locked and limited conversation to collaborators on Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions