Nest JS encountering an error due to an undefined property

Recently, my application was running smoothly until I attempted to fetch the documentation using Swagger. It seems like there might be a dependency issue causing it to stop working, but I can't pinpoint the root of the problem.

An error message keeps popping up:

10:10:22 PM - Starting compilation in watch mode...

Error Cannot read property 'getSymbol' of undefined

I am unsure where 'getSymbol' is utilized within the code, and the error message itself isn't offering much guidance. I'm hopeful that someone can assist me in resolving this issue. You can access the complete source code of the application at:

https://github.com/JSLearningCode/enderecosAlunosAPI

Any help or insights would be greatly appreciated.

UPDATE: While running in development mode, I encountered the following output:

/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/typescript/lib/typescript.js:95877 throw e; ^

TypeError: Cannot read property 'getSymbol' of undefined at Object.isArray (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/@nestjs/swagger/dist/plugin/utils/ast-utils.js:6:25) at getTypeReferenceAsString (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/@nestjs/swagger/dist/plugin/utils/plugin-utils.js:12:21) at Object.getTypeReferenceAsString (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/@nestjs/swagger/dist/plugin/utils/plugin-utils.js:31:29) at ControllerClassVisitor.createTypePropertyAssignment (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/@nestjs/swagger/dist/plugin/visitors/controller-class.visitor.js:51:44) at ControllerClassVisitor.createDecoratorObjectLiteralExpr (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/@nestjs/swagger/dist/plugin/visitors/controller-class.visitor.js:38:18) at ControllerClassVisitor.addDecoratorToNode (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/@nestjs/swagger/dist/plugin/visitors/controller-class.visitor.js:29:22) at visitNode (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/@nestjs/swagger/dist/plugin/visitors/controller-class.visitor.js:16:29) at visitNodes (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/typescript/lib/typescript.js:70998:48) at Object.visitEachChild (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/typescript/lib/typescript.js:71266:355) at visitNode (/home/william/Documentos/lemobs/enderecosAlunosAPI/node_modules/@nestjs/swagger/dist/plugin/visitors/controller-class.visitor.js:18:23) error Command failed with exit code 1.

Answer №1

An obstacle arose concerning the application's routing. Within the controller, I had a parser in place to guide the correct routes for a route labeled "aluno" with the first parameter. After rearranging the routes in the controller and placing the one without parameters at the beginning, the need for the parser vanished, resolving the issue. I hope this explanation proves beneficial to others encountering a similar problem.

Answer №2

Unfortunately, the current solution is not functioning as expected. This could be due to an update in the nestjs swagger plugin.


Previous response:

We recommend verifying the result type of your controller's method

Make this adjustment:

@Contoller()
export class MyController {

// ...
  async myMethod() {
    return {}
  }
}

to:

@Contoller()
export class MyController {

// ...
  async myMethod():Promise<any> {
    return {}
  }
}

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

react-responsive: The children of a Responsive component do not have the capability to receive props

Utilizing the typical scenario described in the README file: const Desktop = props => ( <Responsive {...props} minWidth={1680} maxWidth={2560} /> ) const LaptopL = props => ( <Responsive {...props} minWidth={1440} maxWidth={1679} /> ...

Uncovering secret divs with the power of jQuery timing upon reload

Currently, I am in the process of developing a custom Wordpress theme for my blog which includes an overlay-container. When a button is clicked, this container slides in from the top and pushes down the entire page. To achieve this functionality, I am uti ...

access the data in the fresh window.open

I created a brand new window var win = window.open("", "", "width=400, height=200"); and now I want to access its body using var $windowBody = $(win.document.body); and then use functions like .find() and .html() While this method works smoothly on Fi ...

The use of the "declare" keyword is prohibited within the `script setup` section of Vue

I need to integrate the function getCookie into my Vue file. This function is already defined in the HTML file where the Vue file will be injected. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" ...

Could somebody provide clarification on the functions being called in the Angular Test Code, specifically evaluate() and dragAndDrop()?

Exploring the drag and drop functionality of an angular-Gridster application using Protractor with a test code. I have some questions about the functions being used in the code snippet below. Can someone clarify the purpose of evaluate() - the API definit ...

Choose specific columns from distinct tables and arrange them accordingly

I am facing a challenge with my MySQL database as it contains multiple tables with similar columns, and I want to import this data into a Google spreadsheet. For instance: table1 has id, name, page, and other specific columns. table2 also includes id, n ...

I have a parent DIV with a child DIV, and I am looking to use jQuery to select the last child DIV. The parent DIV has an

In my HTML code, I have a parent div called "allcomments_4" which contains several child divs with unique IDs (oneEntry), each with their own children. My goal is to locate and retrieve the content inside the last child of the parent node (lastComment) and ...

There is a hidden delete button obscured by another element. What steps can be taken to bring that element to the forefront and make it visible?

I'm having trouble positioning a delete button in the top right corner of a collapsible box. Despite setting it to `visibility: visible`, I can't seem to get it to display at the top of the collapsible element. Any suggestions or ideas would be g ...

How to center items within a Toolbar using React's material-ui

I need help with implementing a toolbar on a page that contains three ToolbarGroup components: <Toolbar> <ToolbarGroup firstChild={true} float="left"> {prevButton} </ToolbarGro ...

Sending FormData using Javascript XMLHttpRequest is not functioning as intended

I've been trying to implement a drag'n'drop AngularJS directive to upload files to my server. Despite spending hours on it, I can't seem to find the error in my code. Here's the AngularJS code I have so far: var fd = new FormData( ...

Pressing on an HTML element using JavaScript via the Selenium driver does not trigger the action

I'm attempting to use Selenium with Python to click on an element using JavaScript. Here's a snippet of my code: driver.execute_script("els=document.getElementsByClassName('buttons');\ for (var i = 0; i < els.length; i++) { ...

Bypass Security Check in Firefox

I am facing issues while trying to automate selenium on a website owned by a third party. When an authentication prompt like this appears in Firefox, Selenium fails: https://i.sstatic.net/VHQB4.png You can see a similar situation when clicking the Displ ...

I am constantly reminded by React hooks to include all dependencies

Imagine I am using useEffect to pre-fetch data upon initial rendering: function myComponent(props) { const { fetchSomething } = props; ... ... useEffect(() => { fetchSomething(); }, []); ... ... } My linter is warni ...

Utilize jQuery.ajaxComplete to identify the location of the AJAX request

I have an event: $(document).ajaxComplete that is functioning perfectly. Yet, I am looking to determine whether ajax took place at a particular spot within the document. Is there a method to identify which ajax call was made? $(document).ajaxComplete(fu ...

Angular binding causing decimal inaccuracies

Within my $scope, I have a variable tobing that can be either 2.00 or 2.20, and I am binding it to: <span>{{datasource.tobind}}</span> I want the displayed text to always show "2.00" or "2.20" with the two last digits, but Angular seems to au ...

styles.css is generating an ERROR message, indicating that it is unable to read properties of null when trying to access the 'classList'

Hey there, I've been working on adding a background color change to my navbar when the scrollY exceeds 30px, and it's functioning properly. However, I'm encountering an error in the console which states that the new classList cannot be added ...

How can I specify the array's length when using JSON.stringify in AngularJS?

I am looking to store form values in JSON to send via $http.post. One of the values, rooms, should be an array with a length determined by the selected value from md-select. The value of Adult should be included within each room entry. var data = { rooms: ...

Store the ajax call response in a dynamic function

Currently, I am in the process of creating a series of user-friendly formulas, similar to those found in Excel, for a form builder website. One of the features I have developed is a Lookup function that allows users to specify the value they want and the v ...

Troubleshooting disappearing values in POST request using ajax and jQuery serialize() method

When I make a post request, I am only able to retrieve two out of four values. I am expecting to get the id, step, name, and email from the form but the only ones I receive are from the hidden inputs. It seems like the jQuery serialize() function might be ...

Utilizing multiple instances of fs.writeFile in Node.js

I am currently managing a hotel's check-in/out information on an http server in Node.js. I store all the JSON data in memory and write it to a file using "fs.writeFile". Typically, the data does not exceed 145kB, but when consecutive calls to fs.write ...