Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS Path alias imports not working for spec.ts (the work for .spec.tsx) when using a next project #23394

Open
vespertilian opened this issue May 15, 2024 · 1 comment
Assignees
Labels
scope: nextjs Issues related to NextJS support for Nx type: bug

Comments

@vespertilian
Copy link

Current Behavior

As you can see in this screenshot for some reason the typescript config does not like .ts spec files.

CleanShot 2024-05-15 at 14 21 27@2x

Expected Behavior

I should be able to import "@nx-next-ts-issue/my-new-lib" into .ts spec files.

GitHub Repo

https://github.com/vespertilian/nx-next-ts-issue

Steps to Reproduce

NPM install

open example.spec.ts you should see that it does not want to import helloWorld from @nx-next-ts-issue/my-new-lib.

I checked this in both VS Code and Webstorm

Nx Report

Sample REPO

Node   : 20.11.1
OS     : darwin-arm64
npm    : 10.2.4

nx                 : 19.0.3
@nx/js             : 19.0.3
@nx/jest           : 19.0.3
@nx/linter         : 19.0.3
@nx/eslint         : 19.0.3
@nx/workspace      : 19.0.3
@nx/devkit         : 19.0.3
@nx/eslint-plugin  : 19.0.3
@nx/next           : 19.0.3
@nx/react          : 19.0.3
@nrwl/tao          : 19.0.3
@nx/web            : 19.0.3
@nx/webpack        : 19.0.3
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/next/plugin
@nx/jest/plugin
@nx/eslint/plugin

My repo is a bit older

Node   : 20.11.1
OS     : darwin-arm64
npm    : 10.2.4

nx                 : 18.2.2
@nx/js             : 18.2.2
@nx/jest           : 18.2.2
@nx/linter         : 18.2.2
@nx/eslint         : 18.2.2
@nx/workspace      : 18.2.2
@nx/devkit         : 18.2.2
@nx/esbuild        : 18.2.2
@nx/eslint-plugin  : 18.2.2
@nx/next           : 18.2.2
@nx/node           : 18.2.2
@nx/playwright     : 18.2.2
@nx/react          : 18.2.2
@nrwl/tao          : 18.2.2
@nx/web            : 18.2.2
@nx/webpack        : 18.2.2
typescript         : 5.4.3



### Failure Logs

_No response_

### Package Manager Version

_No response_

### Operating System

- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)

### Additional Information

_No response_
@FrozenPandaz FrozenPandaz added the scope: nextjs Issues related to NextJS support for Nx label May 15, 2024
@terrymun
Copy link

terrymun commented May 18, 2024

It looks like your unit tests are not setup correctly. I remember if you run the config command for vitest or jest it will always regenerate a tsconfig.spec.json file that will include all unit test-like files, including *.spec.ts and *.spec.tsx.

In your reproduction repo the tsconfig.lib.json file is actually excluding all unit test files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: nextjs Issues related to NextJS support for Nx type: bug
Projects
None yet
Development

No branches or pull requests

4 participants