Skip to content

Nx JS TypeScript Plugin Not Inferring Tasks #34243

Description

@capttrousers

Current Behavior

Environment

  • Nx version: 22.3.3
  • @nx/js version: 22.3.3
  • TypeScript version: 5.8.3-5.9.3
  • Workspace: npm workspaces with TypeScript project references
  • Packages: 11 TypeScript packages (buildable libraries)

Problem

The @nx/js/typescript plugin is not inferring build or typecheck tasks. All tasks continue to use nx:run-script executor (inferred from package.json scripts) instead of nx:run-commands executor with proper caching configuration.

Non-Standard Configuration

Our workspace uses .config/ directory for Nx and TypeScript configs:

  • .config/nx.json (not ./nx.json)
  • .config/tsconfig.base.json (not ./tsconfig.base.json)
  • Packages extend: "extends": "../../.config/tsconfig.base.json"

Question: Does the plugin require tsconfig.base.json at workspace root, or should it work with custom config directory structure?

Workaround (Confirms Expected Behavior)

Creating manual project.json with nx:run-commands executor DOES work:

  • Caching functions correctly
  • Cache-hit/cache-miss behaves as expected
  • Proves the issue is plugin inference, not caching mechanism

Expected Behavior

Expected Behavior

Plugin should automatically:

  1. Detect buildable libraries (exports → dist/)
  2. Create build/typecheck targets with nx:run-commands executor
  3. Configure inputs/outputs for caching
  4. Register @nx/js:typescript-sync generator

GitHub Repo

No response

Steps to Reproduce

Evidence

  1. Plugin is registered in .config/nx.json:

    {
      "plugins": [
        {
          "plugin": "@nx/js/typescript",
          "options": {
            "typecheck": { "targetName": "check", "configName": "tsconfig.check.json" },
            "build": { "targetName": "build", "configName": "tsconfig.json" }
          }
        }
      ]
    }
  2. All packages have required setup:

    • tsconfig.json exists (runtime config)
    • package.json has exports pointing to ./dist/* (buildable)
    • composite: true and declaration: true in base config
    • ✅ TypeScript project references configured
  3. But targets show wrong executor:

    npx nx show project domains --json | jq '.targets.build.executor'
    # Returns: "nx:run-script"  (should be "nx:run-commands")
  4. No sync generator registered:

    npx nx sync
    # Output: "There are no sync generators to run"
    # Expected: @nx/js:typescript-sync should run
  5. Test: Removing build script doesn't trigger plugin:

    • Removed "build": "tsc -b" from package.json
    • Result: NO build target created at all
    • Expected: Plugin should infer build target from tsconfig.json

Nx Report

NX   Report complete - copy this into the issue template

Node           : 22.18.0
OS             : linux-x64
Native Target  : x86_64-linux
npm            : 10.9.0

nx             : 22.3.3
@nx/js         : 22.3.3
@nx/workspace  : 22.3.3
@nx/devkit     : 22.3.3
typescript     : 5.9.3
---------------------------------------
Cache Usage: 0.00 B / 95.23 GB

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

Non-Standard Configuration

Our workspace uses .config/ directory for Nx and TypeScript configs:

  • .config/nx.json (not ./nx.json)
  • .config/tsconfig.base.json (not ./tsconfig.base.json)
  • Packages extend: "extends": "../../.config/tsconfig.base.json"

Question: Does the plugin require tsconfig.base.json at workspace root, or should it work with custom config directory structure?

Workaround (Confirms Expected Behavior)

Creating manual project.json with nx:run-commands executor DOES work:

  • Caching functions correctly
  • Cache-hit/cache-miss behaves as expected
  • Proves the issue is plugin inference, not caching mechanism

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions