Skip to content

TS build output not invalidated when node_modules changed #38648

Closed
@brieb

Description

@brieb

Changes to types within node_modules do not invalidate the TypeScript build output.

Suppose we have a project with project references enabled and that there are no TypeScript errors in the project. If we update our node_modules to a new version of a package that contains types, that could introduce errors into our project. However, if we leave the build output directory in place, we do not see these errors in the tsc -b output.

  1. tsc -b -- no errors.
  2. Update types within node_modules that should trigger error.
  3. tsc -b -- no errors, which is unexpected.

Upon inspection of the tsbuildinfo files, the shas for the node_modules d.ts files do not get updated.

We cache our TS output directory between CI builds so that we can incrementally build from it on subsequent builds. We currently invalidate our cache whenever node_modules changes. Ideally, we could keep the cache and TypeScript could figure out what needs to be recompiled.

Separately, it would be great if the validity rules for the TypeScript output were documented as part of the project references docs. That would help us better understand when it is safe to rebuild from an existing output vs requiring a clean build (between TS versions, when node_modules change, etc).

Thank you! 😃

TypeScript Version: 4.0.0-dev.20200518

Search Terms:
project references, build, incremental, node_modules, invalidate, tsb, tsc -b, rebuild, @types

Code

https://github.com/brieb/ts-issue--tsb-nodemodules

Expected behavior:

TS errors reported when types within node_modules change.

Actual behavior:

No TS errors reported.

Errors only reported after editing code within project triggers invalidation.

Related Issues:

#25600

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions