jsep icon indicating copy to clipboard operation
jsep copied to clipboard

fix: update Array elements typing

Open ephys opened this issue 2 years ago • 1 comments

According to this line: https://github.com/EricSmekens/jsep/blob/553833504f2f204964a7d63680da5c8b6471d3ad/src/jsep.js#LL807C24-L807C24, the elements array on array expressions can include null. It has been our experience when parsing an array with holes ([,,,])

This PR updates the typing of ArrayExpression.elements to include null

ephys avatar Mar 16 '23 07:03 ephys

@ephys - could you add a unit test for sparse arrays as well?

Subject: [PATCH] test: add test for sparse arrays
---
Index: test/jsep.test.js
<+>UTF-8
===================================================================
diff --git a/test/jsep.test.js b/test/jsep.test.js
--- a/test/jsep.test.js	(revision e4fdda3a64be74be692b65a35ac6b88c55f32341)
+++ b/test/jsep.test.js	(date 1681591979691)
@@ -54,6 +54,18 @@
 
 	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',

6utt3rfly avatar Apr 15 '23 20:04 6utt3rfly

:tada: This issue has been resolved in version 1.3.9 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Jul 12 '24 23:07 github-actions[bot]