Skip to content

Commit

Permalink
more types
Browse files Browse the repository at this point in the history
  • Loading branch information
kenerwin88 committed Jan 11, 2023
1 parent 85b2985 commit 813fa02
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
54 changes: 27 additions & 27 deletions src/runner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-nocheck

import convertYarn from './convert-yarn-to-js';
import DefaultVariableStorage from './default-variable-storage';
import types from './parser/nodes';
Expand Down Expand Up @@ -107,7 +108,7 @@ export class Runner {
});
}

registerFunction(name, func) {
registerFunction(name: string, func) {
if (typeof func !== 'function') {
throw new Error('Registered function must be...well...a function');
}
Expand Down Expand Up @@ -306,80 +307,80 @@ export class Runner {
}

const nodeHandlers = {
UnaryMinusExpressionNode: (a) => {
UnaryMinusExpressionNode: (a: number) => {
return -a;
},
ArithmeticExpressionAddNode: (a, b) => {
ArithmeticExpressionAddNode: (a: any, b: any) => {
return a + b;
},
ArithmeticExpressionMinusNode: (a, b) => {
ArithmeticExpressionMinusNode: (a: number, b: number) => {
return a - b;
},
ArithmeticExpressionExponentNode: (a, b) => {
ArithmeticExpressionExponentNode: (a: number, b: number) => {
return a ** b;
},
ArithmeticExpressionMultiplyNode: (a, b) => {
ArithmeticExpressionMultiplyNode: (a: number, b: number) => {
return a * b;
},
ArithmeticExpressionDivideNode: (a, b) => {
ArithmeticExpressionDivideNode: (a: number, b: number) => {
return a / b;
},
ArithmeticExpressionModuloNode: (a, b) => {
ArithmeticExpressionModuloNode: (a: number, b: number) => {
return a % b;
},
NegatedBooleanExpressionNode: (a) => {
NegatedBooleanExpressionNode: (a: any) => {
return !a;
},
BooleanOrExpressionNode: (a, b) => {
BooleanOrExpressionNode: (a: any, b: any) => {
return a || b;
},
BooleanAndExpressionNode: (a, b) => {
BooleanAndExpressionNode: (a: any, b: any) => {
return a && b;
},
BooleanXorExpressionNode: (a, b) => {
BooleanXorExpressionNode: (a: number, b: number) => {
// eslint-disable-next-line no-bitwise
return !!(a ^ b);
}, // eslint-disable-line no-bitwise
EqualToExpressionNode: (a, b) => {
EqualToExpressionNode: (a: any, b: any) => {
return a === b;
},
NotEqualToExpressionNode: (a, b) => {
NotEqualToExpressionNode: (a: any, b: any) => {
return a !== b;
},
GreaterThanExpressionNode: (a, b) => {
GreaterThanExpressionNode: (a: number, b: number) => {
return a > b;
},
GreaterThanOrEqualToExpressionNode: (a, b) => {
GreaterThanOrEqualToExpressionNode: (a: number, b: number) => {
return a >= b;
},
LessThanExpressionNode: (a, b) => {
LessThanExpressionNode: (a: number, b: number) => {
return a < b;
},
LessThanOrEqualToExpressionNode: (a, b) => {
LessThanOrEqualToExpressionNode: (a: number, b: number) => {
return a <= b;
},
TextNode: (a) => {
TextNode: (a: { text: any }) => {
return a.text;
},
EscapedCharacterNode: (a) => {
EscapedCharacterNode: (a: { text: string | any[] }) => {
return this.noEscape ? a.text : a.text.slice(1);
},
NumericLiteralNode: (a) => {
NumericLiteralNode: (a: { numericLiteral: string }) => {
return parseFloat(a.numericLiteral);
},
StringLiteralNode: (a) => {
StringLiteralNode: (a: { stringLiteral: any }) => {
return `${a.stringLiteral}`;
},
BooleanLiteralNode: (a) => {
BooleanLiteralNode: (a: { booleanLiteral: string }) => {
return a.booleanLiteral === 'true';
},
VariableNode: (a) => {
VariableNode: (a: { variableName: any }) => {
return this.variables.get(a.variableName);
},
FunctionCallNode: (a) => {
FunctionCallNode: (a: any) => {
return this.evaluateFunctionCall(a);
},
InlineExpressionNode: (a) => {
InlineExpressionNode: (a: any) => {
return a;
},
};
Expand All @@ -397,4 +398,3 @@ export class Runner {
);
}
}

1 change: 0 additions & 1 deletion src/yarn-bound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default class YarnBound {
static CommandResult: CommandResult;
public handleCommand: any;
public combineTextAndOptionsResults: any;
public bondage: any;
public bufferedNode: any;
public currentResult: any;
public history: any;
Expand Down

0 comments on commit 813fa02

Please sign in to comment.