fix(ivy): correctly resolve Array property access (#24664)
PR Close #24664
This commit is contained in:
parent
dcabb05102
commit
3d20c50156
|
@ -460,7 +460,7 @@ class StaticInterpreter {
|
||||||
}
|
}
|
||||||
} else if (Array.isArray(lhs)) {
|
} else if (Array.isArray(lhs)) {
|
||||||
if (rhs === 'length') {
|
if (rhs === 'length') {
|
||||||
return rhs.length;
|
return lhs.length;
|
||||||
}
|
}
|
||||||
if (typeof rhs !== 'number' || !Number.isInteger(rhs)) {
|
if (typeof rhs !== 'number' || !Number.isInteger(rhs)) {
|
||||||
return DYNAMIC_VALUE;
|
return DYNAMIC_VALUE;
|
||||||
|
|
|
@ -112,6 +112,9 @@ describe('ngtsc metadata', () => {
|
||||||
it('array access works',
|
it('array access works',
|
||||||
() => { expect(evaluate(`const a = [1, 2, 3];`, 'a[1] + a[0]')).toEqual(3); });
|
() => { expect(evaluate(`const a = [1, 2, 3];`, 'a[1] + a[0]')).toEqual(3); });
|
||||||
|
|
||||||
|
it('array `length` property access works',
|
||||||
|
() => { expect(evaluate(`const a = [1, 2, 3];`, 'a[\'length\'] + 1')).toEqual(4); });
|
||||||
|
|
||||||
it('negation works', () => {
|
it('negation works', () => {
|
||||||
expect(evaluate(`const x = 3;`, '!x')).toEqual(false);
|
expect(evaluate(`const x = 3;`, '!x')).toEqual(false);
|
||||||
expect(evaluate(`const x = 3;`, '!!x')).toEqual(true);
|
expect(evaluate(`const x = 3;`, '!!x')).toEqual(true);
|
||||||
|
|
Loading…
Reference in New Issue