Nest JS Cannot read property of undefined - javascript

My application was working fine, and it stopped after trying to get the documentation with swagger, i think it may be a dependency issue, but can't find it anywhere.
I keep getting the error
10:10:22 PM - Starting compilation in watch mode...
Error Cannot read property 'getSymbol' of undefined
I don't know where getSymbol is used, and the error doesn't seem to help much. Hope someone can help me fix this issue. The complete application code can be found at:
https://github.com/JSLearningCode/enderecosAlunosAPI
Any help is welcome.
EDIT:
Running in dev mode I got this 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.

There was an issue related to the routing in the application. I had a parser inside the controller that was used for directing correct routes between a route "aluno" with first Param.
Once I had taken the route with no params and put it first at the controller, there was no need anymore for the parser, and the issue was gone. Hope this answer helps more people if they get the same problem.

Please check your method result type of controller
Change this:
#Contoller()
export class MyController {
// ...
async myMethod() {
return {}
}
}
to:
#Contoller()
export class MyController {
// ...
async myMethod():Promise<any> {
return {}
}
}

Related

Typescript displays error for "this" Object saying TS2532: Object is possibly 'undefined' inside of vue methods

As I am still fairly new to writing questions, I apologise for possible misvoicing.
The problem:
I have a vue app with typescript.
export default {
methods: {
setProgram: (program: Program)=>{
this.program = program // TS2532: Object is possibly 'undefined'.
this.step++ // TS2532: Object is possibly 'undefined'.
}
},
...
}
While I really like this feature of typescript, I really am sure, that "this" will not be undefined in this case.
How can I calm typescript down regarding the use of "this"?
Thank you very much everyone,
have a great day ahead!
Best Dom.
Got it!
"this" might be undefined if used inside lambda function :)
just change
setProgram: (program: Program) => {
to:
setProgram: function (program: Program) {
and it works ...

How can I get a json content from another js file?

I have two files:
// roles.js
export function roles() {
return {"/": ["admin","user"]};
}
// router.config.js
import {roles} from '../src/pages/.umi/roles'
console.log(roles['/']);
It throws:
TypeError: Cannot read property '/' of undefined
See? It is undefined. how can I make it accessible?
One of your mistakes is you're importing a function.
You should use roles()['/'] to get value
The other problem about undefined, probably is that you're importing wrong path like they're commenting.
Here you have an example that it runs.
https://stackblitz.com/edit/js-5cquau

emberfire: this._ref.push is not a function

The Issue
I seem to be getting the following error with emberfire, I followed the documentation yet still get the error:
Uncaught TypeError: this._ref.push is not a function
at Class.generateIdForRecord (firebase.js:75)
at Class._generateId (-private.js:10359)
at Class.createRecord (-private.js:10325)
at Class.test (home.js:13)
at Class.send (action_handler.js:32)
at action.js:141
at exports.flaggedInstrument (ember-metal.js:3730)
at action.js:140
at Backburner.run (backburner.js:537)
at run (ember-metal.js:4267)
The following code is where the error comes from, the code is simply placed in an action in a controller called home:
var newGlobal = this.store.createRecord('global', {
about: 'test',
});
newGlobal.save();
The rules on the database are set up as:
{
"rules": {
".read": true,
".write": true
}
}
and the database is empty.
I have also setup config/environment.js
Any ideas please?
Thank you in advance
Helpful Links
emberfire
Emberfire guide
Found these issues but they didn't help with my issue
This is now solved, the issue was I had created a custom ember service called firebase.
I had injected it in the home controller like so:
firebase: Ember.inject.service()

issue with $cordovaContacts

i'm new in stackoverflow forum and i decide to create this topic to solve a problem wich i'm stuck for 2 weeks.
I have the following :
Visual Studio Android Emulator
Ionic 1 project created with the tabs pattern.
I'm trying to use the ngCordova contacts module ( $cordovaContacts ) to retrieve the phone numbers of the contacts. The problem is that there is an error with the "navigator" object. I found that there is not possible to acces the fields of these object ( functions , app , contacts , splashscreen ) so when i call to $cordovaContacts.find(...) it shows the error : "Can not find property find of undefined" . I invested some time debugging and when i use :
console.log(navigator);
The console shows:
[object Object]
services.js (21,15)
CordovaNavigator
_ {_
_ [functions]: ,_
_ proto: { },_
_ app: { },_
_ contacts: { },_
_ splashscreen: { }_
_ }_
But when i print navigator.contacts object it shows undefined
I also tried to use navigator.CordovaNavigator but is also undefined.
This code is called when loading controllers.
I have no idea why it shows that navigator has an atribute contacts and then when i call it it shows UNDEFINED . Maybe i need to stablish some acces rights ??.
I'm really lost so anything you tell me will help. Thanks a lot.
If you are trying to fetch the contacts on controller load (means, that you don't trigger it manually inside another method or via a timeout / interval), you'll need to wrap it with the ionicPlatform.ready() method, else the plugin isn't ready at that point.
ionic.Platform.ready(function(){
$cordovaContacts.find().then(function(allContacts) {
$scope.contacts = allContacts;
});
});

Node.js throwing TypeError: Cannot read property 'testModule' of undefined

So I looked around, looking for solutions for this problem else where and including here, but I keep getting the error
"Cannot read property 'testModule' of undefined."
main.js:
var testing = require('./lib/test.js');
console.log(testing.testModule('user'));
./lib/test.js
module.exports = {
testModule: function(test){
return 'Hello '+test+' from module!';
}
};
What am I doing wrong and what can I do to fix this issue?
Fixed the error.
In my original code (not here) I assigned the variable testing as test and called a variable that was non-existent.
Thanks for the tips on the directory structures, though. I appreciate it.
I suck :(

Categories

Resources