nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.75k stars 2.37k forks source link

NX 20 : react and js generators are not working with typescript 4.9.5 #28934

Open abarghoud opened 1 week ago

abarghoud commented 1 week ago

Current Behavior

When running yarn nx g @nx/js:library --name=hello --no-interactive --dry-run --directory=packages on a monorepo with nx@20, I am getting this error

NX Cannot read properties of undefined (reading 'JsxEmit')

Expected Behavior

Should not generate the library

GitHub Repo

No response

Steps to Reproduce

  1. Create an NX monorepo
  2. Add @nx/js
  3. Make sure typescript version is 4.9.5
  4. Run yarn nx g @nx/js:library --name=hello --no-interactive --dry-run --directory=packages

Nx Report

Node           : 20.11.1
OS             : darwin-arm64
Native Target  : aarch64-macos
yarn           : 1.22.22

nx                 : 20.1.0
@nx/js             : 20.1.0
@nx/eslint         : 20.1.0
@nx/workspace      : 20.1.0
@nx/devkit         : 20.1.0
@nx/eslint-plugin  : 20.1.0
@nx/react          : 20.1.0
@nx/vite           : 20.1.0
@nx/web            : 20.1.0
typescript         : 4.9.5
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin

Failure Logs

NX   Cannot read properties of undefined (reading 'JsxEmit')

TypeError: Cannot read properties of undefined (reading 'JsxEmit')
    at getNeededCompilerOptionOverrides (./node_modules/@nx/js/src/utils/typescript/configuration.js:31:49)
    at createProjectTsConfigs (./node_modules/@nx/js/src/generators/library/library.js:686:88)
    at createFiles (./node_modules/@nx/js/src/generators/library/library.js:334:5)
    at libraryGeneratorInternal (./node_modules/@nx/js/src/generators/library/library.js:43:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ./node_modules/nx/src/command-line/generate/generate.js:240:26
    at async handleErrors (./node_modules/nx/src/utils/handle-errors.js:8:24)
    at async Object.handler (./node_modules/nx/src/command-line/generate/command-object.js:13:22

Package Manager Version

1.22.22

Operating System

Additional Information

After digging into it, I think it caused by this modification https://github.com/nrwl/nx/commit/49c5a73cd04b602d6b71c48713d6d76b745531a1#diff-842db87f6a6e9b32a7f1343a67bc63af9676b4ae0a418ced46628461d3070eb4R56

Where we do ts.server.protocol.JsxEmit while protocol in typescript@4.9.5 is undefined