Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
159
rated 0 times [  163] [ 4]  / answers: 1 / hits: 41134  / 7 Years ago, wed, june 7, 2017, 12:00:00

Here my problem:
I get this error:




Uncaught TypeError: Object prototype may only be an Object or null: undefined




export abstract class AbstractLogicExpression {
protected _logicChildExpressions: AbstractLogicExpression[] = Array();
protected _precedence = 0;
protected _parsed = false;
protected _expressionType = ;

protected rightAssociative = false;

public toDNF() {
for (let i = 0; i < this.logicChildExpressions.length; i++) {
let actualLogicExpression: AbstractLogicExpression = this.logicChildExpressions[i];

if (actualLogicExpression._expressionType == ~) {

let logicConjunction = actualLogicExpression.logicChildExpressions[0];

let var1 = logicConjunction.logicChildExpressions[0];
let var2 = logicConjunction.logicChildExpressions[1];

if (logicConjunction._expressionType == *) {
actualLogicExpression.logicChildExpressions[0] = new LogicOr();
//actualLogicExpression.logicChildExpressions[0].add(new LogicNeg(var1));
//actualLogicExpression.logicChildExpressions[0].add(new LogicNeg(var2));
}
}
}
}
}


I get this error because of the line before the two commented lines:



actualLogicExpression.logicChildExpressions[0] = new LogicOr();


I tested it by comment and uncomment the lines, because I get no line number in the error message.



Does someone know what I can do?
If you need a little more code. I can post something...



Here the code of LogicOr:
https://pastebin.com/T28Zjbtb


More From » typescript

 Answers
60

You get an error on this line:




actualLogicExpression.logicChildExpressions[0] = new LogicOr();




The error message is




Uncaught TypeError: Object prototype may only be an Object or null: undefined




It is very easy to understand once you are familiar with Classes and how they work (https://basarat.gitbooks.io/typescript/docs/classes.html).



The error means that new LogicOr is failing because LogicOr is extending something that is undefined. Simple example:



let Bar; 
class Foo extends Bar { } // Uncaught TypeError: Object prototype may only be an Object or null: undefined


More



Fix the bug in LogicOr and its inheritance chain.


[#57537] Sunday, June 4, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaitlynnb

Total Points: 402
Total Questions: 96
Total Answers: 109

Location: Trinidad and Tobago
Member since Fri, May 8, 2020
4 Years ago
kaitlynnb questions
;