NX's auto importing feature fails to work with shared libraries

I recently set up an NX monorepo with a shared library in Next.js and TypeScript (using "@nx/next": "16.5.1"). In this setup, components from the shared library can be manually imported into the main app using statements like:

import { Typography } from '@frontend/jsx-core';

However, I would prefer to have these imports suggested by auto-import in VSCode. Strangely enough, this feature seems to work in an older project where I used "@nrwl/next": "15.6.3", so I know it's possible.

I've checked all my VSCode settings and even created a new project with the old configuration to see if that solves the issue, but no luck. The auto-suggested imports still don't work in the new projects.

If you want to take a look at the new project without auto-suggested imports, you can find it here: https://github.com/RowinVanAmsterdam/gamesource

For comparison, here's the link to the old project where everything worked smoothly: https://github.com/koiosonline/koios.world--leg

I've combed through every config file, trying to spot any differences and copying them over, but the issue persists.

One interesting observation is that once I manually import a shared component and then attempt to add another one, the auto-import/suggestion feature suddenly kicks in, asking me to update the existing import statement.

In my tsconfig.json:

  "compileOnSave": false,
  "compilerOptions": {
    "rootDir": ".",
    "sourceMap": true,
    ...
    "baseUrl": ".",
    "paths": {
      "@frontend/jsx-core": ["libs/jsx-core/src/index.ts"]
    }
  },
  ...
}

In my tsconfig.base.json:

{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "jsx": "preserve",
    ...
  },
  ...
}

And in my tsconfig.spec.json:

{
  "extends": "./tsconfig.json",
  ...
}

Answer №1

Without any effort on my part, the problem resolved itself. I started a new project and encountered no issues whatsoever. From then on, the problem seemed to vanish into thin air.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In Angular 7, you can create a checklist from an array of objects by incorporating multiple selection and a "select all" feature. Here's how to

I need assistance with creating a list in Angular using ngFor. Each item must have a unique ID and a checkbox, as depicted in the diagram. However, I am struggling to determine how to manage multiple selections, implement a select all feature, and trigge ...

The Swiper grid functionality is failing to function properly

For the past two days, I've been struggling to successfully implement a Swiper Grid feature in my Next.js application. Despite trying various solutions from stackoverflow and experimenting with different approaches, none of them have resulted in the d ...

Each time I attempt to read a single document, Next.js and Firebase consistently encounter serialization errors

Currently, I am in the process of developing a blog website, and most of it is completed except for the functionality of being able to click on a post stub to read the full post. Whenever I try to navigate to the post page, I encounter the following error: ...

What is the process for initiating a local Lambda edge viewer request?

Is there a way to run aws cloudfront lambda edge functions locally and simulate the event in order to observe the response from one of the four functions? I made modifications to the viewerRequest function of lambdaEdge, but I'm wondering if there is ...

What is the best way to retrieve a specific number of documents from MongoDB?

I am currently facing an issue with my code that is returning all news related to a company. However, I only want the first 15 elements. Is there a way to achieve this? The following code snippet retrieves all news for a company using the google-news-jso ...

What role does Next.js play within the realm of React development?

As a newcomer to React, I recently discovered Next.js. While I have a basic understanding that it is a popular tool among React developers, I am unsure of the specific issues it aims to solve within React development. Would anyone be able to provide some ...

Detecting typescript syntax errors: checking for if statements and calling class methods

When I'm debugging, I've noticed that the silly mistakes I make are often the hardest to spot. For example: if (id = userId) {..} And in class methods: let result = myClass.doThis; Oddly enough, VSCode doesn't catch these errors during co ...

Angular: Effective communication between components through routing and Observable binding ultimately results in the advancement of ngtsc(233

I designed an Angular Component named "crear-pedido" that exhibits a catalog of items (using row of products) and my aim is for the user to have the ability to click on the values in the ID column and navigate the application to a subordinate component kno ...

Capable of retrieving information from an API, yet unable to display it accurately within the table structure

I'm currently working with Angular version 13.2.6 and a .NET Core API. I have two components, PaymentdetailsView (parent) and PaymentDetailsForm (child). Within the PaymentDetailsForm component, there is a form that, when submitted, makes a call to ...

Angular2 Navigation Menu

I have a side bar and I want its children to appear when the user clicks on the parent. For example, clicking on LinkTest should display its corresponding content as block. You can check out the Angular and Typescript code snippet at this link: http://jsfi ...

Is there a way to access the value of an IPC message beyond just using console log?

I am developing an app using electron and angular where I need to send locally stored information from my computer. I have successfully managed to send a message from the electron side to the angular side at the right time. However, I am facing issues acce ...

Different methods to prompt TypeScript to deduce the type

Consider the following code snippet: function Foo(num: number) { switch (num) { case 0: return { type: "Quz", str: 'string', } as const; case 1: return { type: "Bar", 1: 'value' } as const; default: thr ...

When logging `self`, the output field is present; however, attempting to log `self.output` results in

I've encountered a strange issue. When I use console.log(self) to log the variable, it shows that the output key is set and contains all the values. However, if I try to log console.log(self.output), it returns undefined. Does anyone know why this is ...

Create a dynamically updating list using React's TypeScript rendering at regular intervals

My goal is to create a game where objects fall from the top of the screen, and when clicked, they disappear and increase the score. However, I am facing an issue where the items are not visible on the screen. I have implemented the use of setInterval to d ...

The Route.ts file does not export any HTTP methods

Encountering an error while trying to migrate code from Next JS 12 with pages router in Javascript to Next JS 13 with TypeScript. ⨯ Detected default export in 'vibe\src\app\api\auth[...nextauth]\route.ts'. Export a name ...

Having trouble dispatching a TypeScript action in a class-based component

I recently switched to using this boilerplate for my react project with TypeScript. I'm facing difficulty in configuring the correct type of actions as it was easier when I was working with JavaScript. Now, being new to TypeScript, I am struggling to ...

Surprising Discovery: TypeScript - node_modules Found in Unusual Directory

Is there a way to make TypeScript imports function properly even if the node_modules directory is not directly in the tree? How can I prevent TypeScript from throwing errors when importing something like rxjs from external/node_modules. For Example: Dir ...

What is the correct way to forcefully override an existing type in TypeScript?

As I work with Formik, a React form library, I find myself creating custom fields and utilizing the generic Schema type provided by Formik. This type represents the values object, which holds all the values for each field in the form. One of the custom co ...

Jasmine reported that there were no specifications found in the Angular project written in TypeScript

I'm facing a frustrating issue with Karma and Jasmine in my Angular 9 project. Despite setting up the configuration files correctly, I keep getting a "No specs found" message when running ng test. I have tried various adjustments, including creating d ...

By default, showcase the value of the first item in the list selected in a mat-selection-list on a separate component

In my project, I have two essential components: 1)list (which displays a list of customers) 2)detail (which shows the details of a selected customer) These components are designed to be reusable and are being utilized within another component called cus ...