Can you use tsc to type check multiple typescript projects at once without building them?
Asked Answered
O

0

12

In theory, you should be able to do this by using references to make a top-level tsconfig file that includes paths to all of the different typescript projects you want to check, setting "composite": true on the tsconfig.json files for each individual project, and then running tsc --project top_level_tsconfig.json --noEmit.

For example, top_level_tsconfig.json could look like this:

{
    "references": [
    {
      "path": "./project1/tsconfig.json"
    },
    {
      "path": "./project2/tsconfig.json"
    }
  ]
}

Running tsc --project top_level_tsconfig.json --noEmit with that setup just gets a bunch of somefile.d.ts has not been built from source file somefile.ts errors, though. This thread talks about why that happens.

tsc --project project1/tsconfig.json --noEmit and tsc --project project2/tsconfig.json --noEmit run just fine, as long as you turn off the "composite": true option, but you can't turn off "composite": true when using the references option. This thread talks about this, but none of the provided solutions seem to help for this case, and there doesn't seem to be any other way to typecheck multiple projects at once with --noEmit.

I know you can use tools like concurrently to just run tsc a bunch of times concurrently, but it would be nice to be able to do this with just tsc if possible. Is there a way?

Ocko answered 14/4, 2021 at 0:16 Comment(1)
I'm trying to find an answer to this as well but I don't think it's possible right now, even almost 2 years later.Swivel

© 2022 - 2024 — McMap. All rights reserved.