Skip to content

@nx/js typecheck does not align with documented TS workspace/ref setup #34274

@TheSnowyxGIT

Description

@TheSnowyxGIT

Current Behavior

The current typecheck target generated by @nx/js/typescript is not compatible with the
TypeScript project references / workspace setup.

The documentation states that both tsconfig.spec.json and tsconfig.lib.json should be
referenced from the project-level tsconfig.json. However, the generated typecheck target
is hardcoded to use tsconfig.json, with no option to configure a different tsconfig file.

As a result, it is currently not possible to use the generated typecheck target to
typecheck only production files with the setup describe in the doc.

Expected Behavior

We should be able to specify which tsconfig to run for the typecheck target
Example:

"plugins": [
    {
      "plugin": "@nx/js/typescript",
      "options": {
        "typecheck": {
          "targetName": "typecheck",
          "configName": "tsconfig.lib.json",
        }
      }
    }

GitHub Repo

No response

Steps to Reproduce

  1. Create a new workspace using Nx with the @nx/js plugin.
  2. Generate a library using @nx/js.
  3. Configure TypeScript project references by following the official documentation:
    https://nx.dev/docs/technologies/typescript/guides/switch-to-workspaces-project-references#update-individual-project-typescript-configuration
    • Create tsconfig.lib.json
    • Create tsconfig.spec.json
    • Configure tsconfig.json to reference both configs
  4. Run the inferred typecheck target for the library.
  5. Observe that test files are included in the typecheck, even though only production files are expected.

Nx Report

Node           : 25.2.0
OS             : linux-x64
Native Target  : x86_64-linux
pnpm           : 10.22.0
daemon         : Available

nx                     : 22.4.2
@nx/js                 : 22.4.1
@nx/eslint             : 22.3.3
@nx/workspace          : 22.4.1
@nx/jest               : 22.4.2
@nx/devkit             : 22.3.3
@nx/esbuild            : 22.3.3
@nx/eslint-plugin      : 22.3.3
@nx/module-federation  : 22.4.2
@nx/nest               : 22.3.3
@nx/next               : 22.4.2
@nx/node               : 22.4.2
@nx/playwright         : 22.3.3
@nx/react              : 22.4.2
@nx/rollup             : 22.4.2
@nx/vite               : 22.4.2
@nx/vitest             : 22.3.3
@nx/web                : 22.3.3
@nx/webpack            : 22.3.3
@nx/docker             : 22.4.2
typescript             : 5.9.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/next/plugin
@nx/eslint/plugin
@nx/vitest
@nx/playwright/plugin
@nx/webpack/plugin
---------------------------------------
Cache Usage: 0.00 B / 1.83 GB
---------------------------------------
The following packages should match the installed version of nx
  - @nx/js@22.4.1
  - @nx/eslint@22.3.3
  - @nx/workspace@22.4.1
  - @nx/devkit@22.3.3
  - @nx/esbuild@22.3.3
  - @nx/eslint-plugin@22.3.3
  - @nx/nest@22.3.3
  - @nx/playwright@22.3.3
  - @nx/vitest@22.3.3
  - @nx/web@22.3.3
  - @nx/webpack@22.3.3

To fix this, run `nx migrate nx@22.4.2`
---------------------------------------
⚠️ Multiple Nx versions detected

Your workspace uses nx@22.4.2, but other packages depend on a different version:
  - @nx/esbuild → @nx/devkit → nx@22.3.3
  - @nx/js → @nx/devkit → nx@22.4.1

These packages should not have nx as a dependency. Please report this issue to the package maintainers.
Run `pnpm why nx@22.3.3` for more details.
Run `pnpm why nx@22.4.1` for more details.

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions