Skip to content

Commit 99c4b59

Browse files
Replace unit test with checkJs test for ElementAccessExpression
Co-authored-by: DanielRosenwasser <[email protected]>
1 parent 215d1e8 commit 99c4b59

File tree

2 files changed

+26
-37
lines changed

2 files changed

+26
-37
lines changed

internal/ast/text_test.go

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// @ts-check
2+
// @checkJs: true
3+
4+
// Create an object with properties
5+
const obj = { staticKey: "value", 0: "numeric" };
6+
7+
// Use ElementAccessExpression with string literal (should work)
8+
const value1 = obj["staticKey"];
9+
10+
// Use ElementAccessExpression with numeric literal (should work)
11+
const value2 = obj[0];
12+
13+
// Use ElementAccessExpression with variable (would trigger the panic before fix)
14+
const dynamicKey = "dynamicKey";
15+
const value3 = obj[dynamicKey];
16+
17+
// Nested ElementAccessExpression (common in webpack code)
18+
const nestedObj = { inner: { deep: "value" } };
19+
const innerKey = "inner";
20+
const deepKey = "deep";
21+
const nestedValue = nestedObj[innerKey][deepKey];
22+
23+
// Create an array and access with ElementAccessExpression
24+
const arr = ["first", "second", "third"];
25+
const idx = 1;
26+
const arrValue = arr[idx];

0 commit comments

Comments
 (0)