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

why typescript throw Cannot find name 'pkg2'? #29757

Closed
jon9090 opened this issue Jan 26, 2025 · 1 comment
Closed

why typescript throw Cannot find name 'pkg2'? #29757

jon9090 opened this issue Jan 26, 2025 · 1 comment

Comments

@jon9090
Copy link

jon9090 commented Jan 26, 2025

Current Behavior

I created an NX workspace using the command npx create-nx-workspace@latest nx-repo and then chose stack: "none" for an empty TS repo.

then I create two js libs. pkg-1 and pkg-2.

in pkg-1 I want to call a function pkg2() that created automatic from the nx g @nx/js:lib command.

the problem is typescript say: Cannot find name 'pkg2'..

Image

those packages are added to tsconfig automatic:

Image

Nx Report

v20.3.3
@gperdomor
Copy link
Contributor

@jon9090 you need to import the function pkg2 from your pkg-2 library in your pkg-1.ts file...

TS references replace path aliases, but they are still 2 different libraries packages and you need to export and import functions like before

@jon9090 jon9090 closed this as completed Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants