Skip to content

Commit

Permalink
fix: test gh actions from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
6utt3rfly committed Jul 6, 2024
1 parent f6ff791 commit d856077
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export interface HookScope {
gobbleArguments: (untilICode: number) => PossibleExpression;
gobbleGroup: () => Expression;
gobbleArray: () => PossibleExpression;
throwError: (msg: string) => void;
throwError: (msg: string) => never;
}
```

Expand Down
12 changes: 7 additions & 5 deletions src/jsep.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ export class Jsep {
object: node,
property: this.gobbleExpression()
};
if (!node.property) {
this.throwError('Unexpected "' + this.char + '"');
}
this.gobbleSpaces();
ch = this.code;
if (ch !== Jsep.CBRACK_CODE) {
Expand Down Expand Up @@ -963,12 +966,11 @@ Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);

// Backward Compatibility:
const jsep = expr => (new Jsep(expr)).parse();
const staticMethods = Object.getOwnPropertyNames(Jsep);
staticMethods
const stdClassProps = Object.getOwnPropertyNames(class Test{});
Object.getOwnPropertyNames(Jsep)
.filter(prop => !stdClassProps.includes(prop) && jsep[prop] === undefined)
.forEach((m) => {
if (jsep[m] === undefined && m !== 'prototype') {
jsep[m] = Jsep[m];
}
jsep[m] = Jsep[m];
});
jsep.Jsep = Jsep; // allows for const { Jsep } = require('jsep');
export default jsep;
Expand Down
14 changes: 13 additions & 1 deletion test/jsep.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {testParser, testOpExpression, esprimaComparisonTest, resetJsepDefaults}
type: 'MemberExpression',
optional: true,
}, assert);
assert.throws(() => jsep('[1,2][]'), 'Unexpected "]"');
});

QUnit.test('Function Calls', function (assert) {
Expand All @@ -54,7 +55,18 @@ import {testParser, testOpExpression, esprimaComparisonTest, resetJsepDefaults}

QUnit.test('Arrays', function (assert) {
testParser('[]', { type: 'ArrayExpression', elements: [] }, assert);

testParser('[,,1]', {
type: 'ArrayExpression',
elements: [
null,
null,
{
raw: '1',
type: 'Literal',
value: 1
}
],
}, assert);
testParser('[a]', {
type: 'ArrayExpression',
elements: [{ type: 'Identifier', name: 'a' }],
Expand Down
24 changes: 21 additions & 3 deletions typings/tsd.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ declare module 'jsep' {

export interface ArrayExpression extends Expression {
type: 'ArrayExpression';
elements: Expression[];
/** The expression can be null in the case of array holes ([ , , ]) */
elements: Array<null | Expression>;
}

export interface BinaryExpression extends Expression {
Expand All @@ -30,6 +31,11 @@ declare module 'jsep' {
body: Expression[];
}

export interface SequenceExpression extends Expression {
type: 'SequenceExpression';
expressions: Expression[];
}

export interface ConditionalExpression extends Expression {
type: 'ConditionalExpression';
test: Expression;
Expand Down Expand Up @@ -69,6 +75,7 @@ declare module 'jsep' {

export type ExpressionType =
'Compound'
| 'SequenceExpression'
| 'Identifier'
| 'MemberExpression'
| 'Literal'
Expand All @@ -84,6 +91,7 @@ declare module 'jsep' {
| BinaryExpression
| CallExpression
| Compound
| SequenceExpression
| ConditionalExpression
| Identifier
| Literal
Expand All @@ -110,7 +118,7 @@ declare module 'jsep' {
gobbleArguments: (untilICode: number) => PossibleExpression;
gobbleGroup: () => Expression;
gobbleArray: () => PossibleExpression;
throwError: (msg: string) => void;
throwError: (msg: string) => never;
}

export type HookType = 'gobble-expression' | 'after-expression' | 'gobble-token' | 'after-token' | 'gobble-spaces';
Expand Down Expand Up @@ -145,14 +153,24 @@ declare module 'jsep' {

function addUnaryOp(operatorName: string): void;

function addLiteral(literalName: string, literalValue: any): void;

function addIdentifierChar(identifierName: string): void;

function removeBinaryOp(operatorName: string): void;

function removeUnaryOp(operatorName: string): void;

function addIdentifierChar(identifierName: string): void;
function removeLiteral(literalName: string): void;

function removeIdentifierChar(identifierName: string): void;

function removeAllBinaryOps(): void;

function removeAllUnaryOps(): void;

function removeAllLiterals(): void;

const version: string;
}

Expand Down

0 comments on commit d856077

Please sign in to comment.