Skip to content

tsconfig extends property makes tsc scanning files its shouldn't (causing serious slowdown on compilation) #14539

Closed
@Bnaya

Description

@Bnaya

TypeScript Version: 2.2.1

Description of the issue:
When a tsconfig extends another tsconfig-base,
tsc will scan all of the files and directories that are siblings of the extended tsconfig-base, including any node modules and unrelated files.
Probably tsc thinks its also a program root(?)
Even that the docs specifics that files, include and exclude from the inheriting config file overwrite those from the base config file.

A side note: adding include: [] tsconfig-base solved the issue. but the default behaviour is problematic.

On this travis build log you can see the output of strace on tsc with a repro of the described behaviour, listing all of the stat operations.
You can see that there are alot of files that not supposed to be accessed by the tsc, being lstat
https://travis-ci.org/brandtotal/missbehave-tsconfig-extend/jobs/208978852

A sample of the log:

...
stat("/home/travis/build/brandtotal/missbehave-tsconfig-extend/bad-test-case/tsconfig-base.json", {st_mode=S_IFREG|0664, st_size=148, ...}) = 0
fstat(9, {st_mode=S_IFREG|0664, st_size=148, ...}) = 0
stat("/home/travis/build/brandtotal/missbehave-tsconfig-extend/bad-test-case/proj1", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/home/travis/build/brandtotal/missbehave-tsconfig-extend/bad-test-case/this-file-is-not-expected-to-be-lstat-by-tsc.ts", {st_mode=S_IFREG|0664, st_size=0, ...}) = 
...

On the good test-case, where i've added include: [] to the tsconfig-base, there is not access to this-file-is-not-expected-to-be-lstat-by-tsc.ts

The code is available here:
https://github.com/brandtotal/missbehave-tsconfig-extend

On small projects and fast machines its not very noticeable.
On complex projects it can make tsc stat hundreds of thousands of files, causing serious slowdown.

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